[android]无法删除 extra space 卡片视图-项目-可滚动 RecyclerView 之间

发布时间: 2016/9/16 13:25:40
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

伙计们,

我在尝试删除选项 extra space 在我下面的 recyclerview 卡片视图-项之间是电流输出。请建议。

enter image description here

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#303030"
    android:id="@+id/cv"
    android:layout_marginTop="2dip"
    android:layout_marginBottom="2dip"
    card_view:cardUseCompatPadding="true"
    card_view:cardElevation="5dp"
    android:foreground="?android:attr/selectableItemBackground"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:padding="5dp"
        android:longClickable="true"
        android:background="#303030">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/person_photo"
            android:background="@drawable/vector_red"
            android:layout_alignBottom="@+id/txtSub" />


        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="Large Text"
            android:id="@+id/txtMain"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/person_photo"
            android:layout_toEndOf="@+id/person_photo"
            android:elevation="4dp"
            android:textSize="20dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Small Text"
            android:id="@+id/txtSub"
            android:layout_below="@+id/txtMain"
            android:layout_toRightOf="@+id/person_photo"
            android:layout_toEndOf="@+id/person_photo" />

    </RelativeLayout>

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

我回收view

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeFragment">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    card_view:cardUseCompatPadding="false"
    card_view:cardPreventCornerOverlap="false"
    android:background="#0fffffff" />

 </RelativeLayout>

解决方法 1:

我没有执行 RecyclerView ,然而我已复制中线性两行 layout ,空白的页面从你原来的问题︰

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:background="#303030"
        android:id="@+id/cv1"
        card_view:cardElevation="5dp"
        android:foreground="?android:attr/selectableItemBackground"
        xmlns:android="http://schemas.android.com/apk/res/android">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_margin="4dp"
            android:longClickable="true"
            android:background="#303030">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/person_photo"
                android:background="@drawable/vector_red"
                android:layout_alignBottom="@+id/txtSub" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Large Text"
                android:id="@+id/txtMain"
                android:layout_alignParentTop="true"
                android:layout_toRightOf="@+id/person_photo"
                android:layout_toEndOf="@+id/person_photo"
                android:elevation="4dp"
                android:textSize="20dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="Small Text"
                android:id="@+id/txtSub"
                android:layout_below="@+id/txtMain"
                android:layout_toRightOf="@+id/person_photo"
                android:layout_toEndOf="@+id/person_photo" />

        </RelativeLayout>

    </android.support.v7.widget.CardView>
    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:background="#303030"
        android:id="@+id/cv1"
        card_view:cardElevation="5dp"
        android:foreground="?android:attr/selectableItemBackground"
        xmlns:android="http://schemas.android.com/apk/res/android">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_margin="4dp"
            android:longClickable="true"
            android:background="#303030">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/person_photo"
                android:background="@drawable/vector_red"
                android:layout_alignBottom="@+id/txtSub" />


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Large Text"
                android:id="@+id/txtMain"
                android:layout_alignParentTop="true"
                android:layout_toRightOf="@+id/person_photo"
                android:layout_toEndOf="@+id/person_photo"
                android:elevation="4dp"
                android:textSize="20dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="Small Text"
                android:id="@+id/txtSub"
                android:layout_below="@+id/txtMain"
                android:layout_toRightOf="@+id/person_photo"
                android:layout_toEndOf="@+id/person_photo" />

        </RelativeLayout>

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

</LinearLayout>

玩弄填充,你会得到更好的结果。你也可以尝试添加背景 color 您的信用卡,然后你可以摆脱的 layout 你相对位置版面配置的边缘 !

官方微信
官方QQ群
31647020