Java Android 删除 recyclerview 中项目的轮廓
Java Android Remove the outline of items in a recyclervciew
我正在开发一个 activity 来在我的 Firebase 实时数据库中搜索用户,我正在使用 cradview 作为布局来膨胀:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
android:elevation="0dp"
android:layout_marginBottom="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="@+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardBackgroundColor="@color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="@+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="@color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="@+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="@+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_alignStart="@+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
但是,我注意到当 recyclerview 输出项目时,项目显示有轮廓:
我以为是海拔,所以我在recyclerview和cardview中的布局上都将它设置为0,但结果没有改变。请问有谁知道怎么解决吗?
编辑:
我试图移除边距底部,但它仍然显示高程:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
card_view:cardElevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="@+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="@+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="@color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="@+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="@+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_alignStart="@+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
使用
card_view:cardElevation="0dp"
而不是
android:elevation="0dp"
除了 android:elevation
为 0dp
之外,只需从 <com.google.android.material.card.MaterialCardView />
中删除 android:layout_marginBottom="20dp"
,然后为 children 添加 android:padding
在其中查看以使间距
添加以下代码行以禁用 outlineProvider
:
android:outlineProvider="none"
我正在开发一个 activity 来在我的 Firebase 实时数据库中搜索用户,我正在使用 cradview 作为布局来膨胀:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
android:elevation="0dp"
android:layout_marginBottom="20dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="@+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardBackgroundColor="@color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="@+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="@color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="@+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="@+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_alignStart="@+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
但是,我注意到当 recyclerview 输出项目时,项目显示有轮廓:
我以为是海拔,所以我在recyclerview和cardview中的布局上都将它设置为0,但结果没有改变。请问有谁知道怎么解决吗?
编辑:
我试图移除边距底部,但它仍然显示高程:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="90dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:backgroundTint="#FFFFFF"
card_view:cardElevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="@+id/crdProfileImage"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
app:cardElevation="0dp"
app:cardBackgroundColor="@color/textC"
app:cardCornerRadius="30dp">
<ImageView
android:id="@+id/imgHolder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/user_default"
android:scaleType="centerCrop"/>
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/txtUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="@color/black"
android:layout_marginTop="5dp"
android:fontFamily="sans-serif"
android:textStyle="bold"
android:layout_toEndOf="@+id/crdProfileImage"
android:layout_marginLeft="25dp"
android:textSize="25dp"/>
<TextView
android:id="@+id/txtBio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:layout_alignStart="@+id/txtUsername"
android:layout_marginTop="35dp"
android:text="Hi, this is my biography."/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
使用
card_view:cardElevation="0dp"
而不是
android:elevation="0dp"
除了 android:elevation
为 0dp
之外,只需从 <com.google.android.material.card.MaterialCardView />
中删除 android:layout_marginBottom="20dp"
,然后为 children 添加 android:padding
在其中查看以使间距
添加以下代码行以禁用 outlineProvider
:
android:outlineProvider="none"