【问题标题】:Removing the padding in a RecyclerView删除 RecyclerView 中的填充
【发布时间】:2019-06-20 00:09:32
【问题描述】:

我有带有 cardview 根布局的水平 recyclerview,它有巨大的填充

cardview 应该在 textview 的末尾结束

这里是 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="@android:color/darker_gray">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hint="@string/main_category_name"
    android:id="@+id/mainCategoryName"
    android:layout_centerInParent="true"
    android:textColor="@android:color/black"
    android:textSize="16sp"
    android:textStyle="bold"/>

</android.support.v7.widget.CardView>

这是第二个文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
tools:context=".ShoppingPackage.MainShoppingActivity">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/mainCategoriesRecyclerView"
    android:background="@android:color/white"
    android:clipToPadding="false"/>

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/mainCategoriesRecyclerView"
    android:id="@+id/subCategoriesRecyclerView"
    android:clipToPadding="false"/>

 </RelativeLayout>

【问题讨论】:

    标签: android android-recyclerview padding


    【解决方案1】:

    答案是删除hint我不知道为什么但是提示似乎给出了填充,所以我使用了text并且我没有填充了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 2015-04-21
      • 2021-04-20
      • 2011-02-14
      • 2021-04-30
      • 1970-01-01
      • 2012-12-27
      相关资源
      最近更新 更多