Android cardview第一项和最后一项未正确显示

问题描述 投票:0回答:1

Cardview first item

所以我按照ude * y的Android教程,一切都很完美,唯一的问题是cardview的第一个和最后一个项目没有正确显示。

android android-layout kotlin android-cardview
1个回答
0
投票

我认为你必须要求保证金或填充。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"
        tools:context=".MainActivity">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
        <TextView
            android:id="@+id/empty_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableTop="@drawable/tryagain"
            android:gravity="center"
            android:visibility="gone"
            android:text="@string/no_data_available" />
    </RelativeLayout>

</LinearLayout>

您想要查看更多完整的卡片视图示例,请关注此github:

https://github.com/dharmakshetri/CardViewExample/blob/master/app/src/main/res/layout/main.xml

和完整源代码:CardViewExample

© www.soinside.com 2019 - 2024. All rights reserved.