'CardView remove border
I want too remove a border on my cardView. I try set elavation to 0 dp , app:cardPreventCornerOverlap to false and app:cardUseCompatPadding to true , but I can not remove a border from CardView this is my xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:background="@android:color/transparent"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/IMKAWhite"
android:layout_gravity="center"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
android:elevation="0dp">
<RelativeLayout
android:id="@+id/card"
android:background="@color/IMKAWhite"
android:layout_width="150sp"
android:layout_height="match_parent">
<ImageView
android:layout_width="150sp"
android:layout_height="150sp"
android:id="@+id/profile_photo"
android:adjustViewBounds="true"
android:background="@color/colorPrimary"
android:layout_centerHorizontal="true" />
<TextView
android:layout_below="@+id/profile_photo"
android:id="@+id/profile_name"
android:layout_marginTop="10sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textStyle="bold"
android:textColor="@color/background_tutorial"
android:textSize="@dimen/text_dp_25"
android:gravity="center"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bt_edit_profile"
android:layout_below="@+id/profile_name"
android:layout_marginTop="@dimen/text_dp_25"
android:layout_centerHorizontal="true"
android:textSize="@dimen/text_dp_16"
android:padding="5sp"
android:textColor="@color/background_tutorial"
android:background="@drawable/ic_bt_edit"
android:text="@string/edit_profile"
android:gravity="center" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
this is my screen : [![enter image description here][1]][1]
I try doi this :
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
android:elevation="0dp"
But steal I have a border
Solution 1:[1]
use
card_view:cardElevation="0dp"
instead of android:elevation="0dp"
import the namespace in root element:
xmlns:card_view="http://schemas.android.com/apk/res-auto"
If you're not gonna use elevation and you don't want any border in this layout, just get rid of the CardView
element and keep the your views in your RelativeLayout
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |