【问题标题】:Android cardview first item and last item not showing correctlyAndroid cardview 第一项和最后一项未正确显示
【发布时间】:2019-03-01 16:25:26
【问题描述】:

所以我按照 ude*y 的 Android 教程进行操作,一切正常,唯一的问题是 cardview 的第一项和最后一项没有正确显示。

【问题讨论】:

  • 你能添加你的cardview元素的xml和用于设置RecyclerView的代码吗?
  • 与我们分享您的 XML。但据我所知,您的回收站视图不在工具栏下方。您必须将它设置在工具栏下方或给它一个边距顶部
  • 欢迎您,您的问题太笼统了-请阅读How to ask good question
  • 请分享CardViewMainActivity的XML代码。

标签: android android-layout kotlin android-cardview


【解决方案1】:

我认为您必须根据需要设置边距或填充。

<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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-24
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 2017-02-17
    相关资源
    最近更新 更多