在RecyclerView中删除填充

时间:2019-01-26 10:19:17

标签: android android-recyclerview padding

我的水平recyclerview带有cardview根目录布局,并且填充很大

enter image description here

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>

1 个答案:

答案 0 :(得分:0)

答案是删除->,我不知道为什么,但是提示似乎提供了填充,所以我使用了$mailData = [ 'name' => $request->first_name." ".$request->last_name, 'email' => $request->email, 'subject' => $request->subject, 'message' => $request->message ]; 并且我不再需要填充了。