Open jiansheliuxing opened 7 years ago
这是fragment的layout ` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.lsjwzh.widget.recyclerviewpager.RecyclerViewPager android:id="@+id/base_song_list_pager" android:layout_width="match_parent" android:layout_height="match_parent" app:rvp_triggerOffset="0.1" app:rvp_singlePageFling="true" android:clipToPadding="false"/> </RelativeLayout>
`
然后在createViewHolder
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_layout_single_item, null); return new ViewHolder(view); } common_layout_single_item的布局
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_layout_single_item, null); return new ViewHolder(view); }
RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" android:clipToPadding="false"> <TextView android:id="@+id/common_text_index" android:layout_width="50dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:gravity="center_vertical" android:text="01" />
<TextView android:id="@+id/common_text_item_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/common_text_index" android:layout_centerVertical="true" android:textColor="@color/white" android:text="可惜不是你"/> <LinearLayout android:id="@+id/common_container_operation" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerVertical="true" android:layout_alignParentRight="true" android:orientation="horizontal"> <ImageView android:id="@+id/common_btn_01" android:layout_width="18dp" android:layout_height="18dp" android:layout_marginRight="10dp" android:layout_gravity="center_vertical" android:scaleType="fitXY" android:src="@drawable/ic_audiotrack_white_18dp" android:background="@drawable/common_operation_btn_bg" android:focusable="true" android:focusableInTouchMode="true" android:visibility="visible"/> <ImageView android:id="@+id/common_btn_02" android:layout_width="18dp" android:layout_height="18dp" android:layout_marginRight="10dp" android:layout_gravity="center_vertical" android:scaleType="fitXY" android:src="@drawable/ic_add_white_18dp" android:background="@drawable/common_operation_btn_bg" android:focusable="true" android:focusableInTouchMode="true" android:visibility="visible"/> </LinearLayout>
/RelativeLayout
但出来的效果并没有达到ViewPager的效果,也就是横向方向上没有matchparent,每一个item看上去是wrapcontent的,看上去还跟普通的RecyclerView一个样子
同问
这是fragment的layout ` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto">
`
然后在createViewHolder
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.common_layout_single_item, null); return new ViewHolder(view); }
common_layout_single_item的布局RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" android:clipToPadding="false"> <TextView android:id="@+id/common_text_index" android:layout_width="50dp" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:gravity="center_vertical" android:text="01" />
/RelativeLayout
但出来的效果并没有达到ViewPager的效果,也就是横向方向上没有matchparent,每一个item看上去是wrapcontent的,看上去还跟普通的RecyclerView一个样子