Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android layout 如何在Android中删除此recyclerview元素中的额外空间?_Android Layout_Android Recyclerview - Fatal编程技术网

Android layout 如何在Android中删除此recyclerview元素中的额外空间?

Android layout 如何在Android中删除此recyclerview元素中的额外空间?,android-layout,android-recyclerview,Android Layout,Android Recyclerview,我在Android中实现了一个Recycler视图来创建一个列表,但由于某些原因,我在两个元素之间看到了一个空格,我无法确定错误的位置。至于为什么会发生这种情况,我的猜测是关于行元素XML 回收视图 尝试降低您的值 android:layout_height=“50dp” 如果它不起作用,请尝试减少其他视图中的值这是因为回收器视图高度。尝试将recyclerview高度更改为wrap_内容。并在线性布局的cardview布局中使用高度wrap_内容 请为您的cardview尝试以下代

我在Android中实现了一个Recycler视图来创建一个列表,但由于某些原因,我在两个元素之间看到了一个空格,我无法确定错误的位置。至于为什么会发生这种情况,我的猜测是关于行元素XML


回收视图



尝试降低您的值 android:layout_height=“50dp”
如果它不起作用,请尝试减少其他视图中的值

这是因为回收器视图高度。尝试将recyclerview高度更改为wrap_内容。并在线性布局的cardview布局中使用高度wrap_内容

请为您的cardview尝试以下代码:

 <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cardview1="http://schemas.android.com/apk/res-auto"
    android:id="@+id/row_top_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

<android.support.v7.widget.CardView
    android:id="@+id/pos_cv"
    android:layout_width="match_parent"
    android:layout_height="72dp"
    android:clickable="true" 
    android:layout_marginBottom="10dp"
    cardview1:cardCornerRadius="6dp"
    cardview1:cardElevation="4dp"
    cardview1:cardMaxElevation="6dp">

    <TextView
        android:id="@+id/manager1"
        android:layout_width="220dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="15dp"
        android:text="Store Manager/Branch"
        android:textSize="14sp"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/retail"
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="30dp"
            android:text="Abc Retail"
            android:textSize="10sp" />

        <View
            android:layout_width="170dp"
            android:layout_height="match_parent" />

        <TextView
            android:id="@+id/amount"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:text="25,000"
            android:textColor="@color/colorDarkPink"
            android:textSize="14sp"
            android:textStyle="bold" />

    </LinearLayout>

    <TextView
        android:id="@+id/address"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="50dp"
        android:text="Abc Retail"
        android:textSize="10sp" />

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


您是指布局高度吗?好的,将线性布局高度降低到80dp是可行的,非常感谢!!但是我现在不能看到所有的瓷砖recyclerview高度是wrap_内容,尝试了cardview布局来wrap_内容,同样的结果也是wrap的recyclerview这看起来很有效,非常感谢,你知道如何添加一个滚动到recyclerview的滚动视图吗,但它在9个视图或9个平铺后开始,我想将其限制为4个平铺,然后滚动以查看更多