我试图制作像this image中的水平回收视图,左侧的屏幕截图
我设法做了水平部分,但是没有显示下一张和预览卡。
这里是xml recyclerview
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_cards"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="horizontal"
android:requiresFadingEdge="horizontal"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/recyclerview_card_row" />
这里是recyclerview_card_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipToPadding="false"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_qicard_accent"
android:elevation="5dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@drawable/qicard_card"
android:gravity="bottom"
android:layoutDirection="ltr"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/tv_card_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@null"
android:gravity="center"
android:hint="* * * * * * * * * * * * 6968"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
这里是recyclerview的活动代码
rv_cards = (RecyclerView) findViewById(R.id.rv_cards);
rv_cards.setHasFixedSize(true);
rv_cards.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(rv_cards);