【发布时间】:2017-03-24 00:57:41
【问题描述】:
我想像这张图一样开发List
我曾经使用 RecylerView ItemDecorator 进行重叠。但它是重叠的,没有阴影。屏幕和装饰器代码如下
public class OverlapDecoration extends RecyclerView.ItemDecoration {
private final static int vertOverlap = -50;
@Override
public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.set(0, 0, 0, vertOverlap);
}
}
card_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:tag="cards main container">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="@color/color_white"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<TextView
android:id="@+id/textViewName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:text="Android Name"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</android.support.v7.widget.CardView>
</LinearLayout>
【问题讨论】:
-
我不确定这是否会完全满足您的需要,但如果您在 recyclerview 项目中使用 cardviews,请尝试使用海拔属性并尝试。
-
我在“card_layout.xml”中使用高程。请检查上述修改后的问题。
-
使用卡片视图而不是物品装饰器并管理卡片之间的空间。
-
请输入您的适配器代码。
标签: android android-recyclerview android-cardview cardview