Shape's stroke doesn't appear - android

I defined a Drawable with a stroke but the stroke does not appear on the UI.
<ImageView
android:id="#+id/otherSecurityLaneImageView"
android:layout_width="130dp"
android:layout_height="52dp"
android:layout_marginStart="10dp"
android:padding="10dp"
android:background="#drawable/ll_rounded_corners_6dp"
android:backgroundTint="#color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="#drawable/poi_icon_security_lane_clear" />
Here's how #drawable/ll_rounded_corners_6dp is defined:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="20dp" android:color="#color/ll_red" />
<corners android:radius="6dp" />
</shape>
I expected to see a fat red border around the ImageView in the Android Studio design view but none appears.

You can use various combinations:
app:backgroundTint="#android:color/holo_green_light"
app:backgroundTintMode="multiply"
ll_rounded_corners_6dp.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="20dp" android:color="#android:color/holo_red_dark" />
<corners android:radius="6dp" />
<solid android:color="#android:color/holo_blue_dark" />
</shape>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
tools:context=".MainActivity">
<ImageView
android:id="#+id/ImageView1"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/ll_rounded_corners_6dp"
android:padding="10dp"
android:src="#mipmap/ic_launcher_round"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/ImageView2"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/ll_rounded_corners_6dp"
android:padding="10dp"
android:src="#mipmap/ic_launcher_round"
app:backgroundTint="#android:color/holo_green_light"
app:backgroundTintMode="multiply"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/ImageView1" />
<ImageView
android:id="#+id/ImageView3"
android:layout_width="150dp"
android:layout_height="60dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/ll_rounded_corners_6dp"
android:padding="10dp"
android:src="#mipmap/ic_launcher_round"
app:backgroundTint="#android:color/holo_blue_light"
app:backgroundTintMode="screen"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/ImageView2" />
</android.support.constraint.ConstraintLayout>

I tried your code. Your drawable code is fine.
But to show stroke, There are need some changes in layoit xml code,
Just remove android:backgroundTint="#color/white" because of background tint color stroke does not appear, the main cause of it is that backgroundTint set the color into background of ImageView.
If you need to use backgroundTint you can use same color as stroke color.
Please try below code:
<ImageView
android:id="#+id/otherSecurityLaneImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:padding="10dp"
android:background="#drawable/ll_rounded_corners_6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="#mipmap/ic_launcher" />
I hope its working for you.

After trial and error I got the stroke to appear by removing the android:backgroundTint parameter from the ImageView. I could not find documentation about it. I also tried different android:tintModes but none of them helped.

Related

How to draw a rounded corners layout in android

I'm writing a sample app in android studio and I want to have a layout with rounded corners in front of parent layout. so I've created a shape and apply it to background of the layout but I don't saw a desired result.
note: both layouts are ConstraintLayout
below is my main activity xml code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:scaleType="centerCrop"
android:src="#drawable/flv_bridge"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".27"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.005" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="#drawable/vie_bg" **-----------------> this is my target**
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".78"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1">
<androidx.viewpager.widget.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_percent=".7"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tab_layout" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab_google"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:backgroundTint="#color/white"
android:elevation="35dp"
android:src="#drawable/googleicon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view_pager" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab_facebook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_marginRight="10dp"
android:backgroundTint="#color/white"
android:elevation="35dp"
android:src="#drawable/facebookicone"
app:flow_firstHorizontalBias="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/fab_google"
app:layout_constraintHorizontal_bias="0.483"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/view_pager"
app:layout_constraintVertical_bias="0.0" />
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="#+id/imageView2"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="#drawable/taminlogo"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintEnd_toEndOf="#+id/imageView"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageView"
app:layout_constraintVertical_bias="0.094" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/logo"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="18sp"
app:layout_constraintVertical_bias=".2"
app:layout_constraintBottom_toTopOf="#+id/constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
and the shape xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#color/white"/>
<corners android:topLeftRadius="40dp"
android:topRightRadius="40dp"/>
</shape>
best regards
Try Like This
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f6faff"/>
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
OR
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#f6faff"/>
<corners
android:radius="20dp" />
</shape>
In Your Layoutfile
android:background="#drawable/you_rounded_corner_file_from_drawable"
just set your shape xml file in background attribute in the layout which you want to be round , and after that if you cant see the result , maybe the shape color and your parent layout background color are the same color

I have a button, and I have cornerRadius but it isn't working

I have a button and I gave the cornerRadius attribute. In the xml code, the app appears o be curved but when I run the app, the button is rectangular in shape.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/res_item"
android:forceDarkAllowed="false"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="70dp">
<ImageView
android:id="#+id/res_item_image"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:src="#drawable/ic_icon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.494" />
<TextView
android:id="#+id/res_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:fontFamily="#font/salsa"
android:text="Name"
android:textColor="#color/black"
android:textSize="20sp"
app:layout_constraintEnd_toStartOf="#+id/add"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="#id/res_item_image"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/res_item_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/salsa"
android:text="price"
app:layout_constraintTop_toBottomOf="#id/res_item_name"
app:layout_constraintStart_toEndOf="#id/res_item_image"
android:layout_marginLeft="20dp"
android:textColor="#color/tomato_red"
android:textSize="18sp" />
<Button app:cornerRadius="20dp"
android:id="#+id/add"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_margin="20dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="30dp"
android:text="Add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Instead of this button I also used material button, but still the same happens. It appears to be curved in the XML design, but it isn't in the app.
If you are using a Material theme, then you have to use app:shapeAppearance instead of app:cornerRadius. See details
At first create a shape style in your styles.xml:
<style name="ShapeAppearance.App.SmallComponent" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerSize">20dp</item>
</style>
And in your Button, remove app:cornerRadius and use this shape style:
<com.google.android.material.button.MaterialButton app:shapeAppearance="#style/ShapeAppearance.App.SmallComponent"
android:id="#+id/add"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_margin="20dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="30dp"
android:text="Add"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Create a new file in the drawable folder called for example ripple.xml and use this code:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#color/primary">
<item>
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary"/>
<corners android:radius="20dp" />
</shape>
</item>
</ripple>
And now use the created file as background for your button:
<Button
android:id="#+id/add"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_margin="20dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="30dp"
android:text="Add"
android:background="#drawable/ripple"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
If you want to create rounded corner button then
Create a xml file in your drawable folder like button_shape.xml and paste the following code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#50B771" />
<corners android:radius="5dp" />
</shape>
Then set the selector file into your button in the xml:
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:textColor="#ffffff"
android:background="#drawable/button_shape"
android:text="Buttons" />
If you have again doubt on this you can ping me.

Change custom dialog shape color with dark or light mode

I am using custom rounded backgrounds for dialogs in my Android Studio app but am running into a problem. I have specified the color of the shape to be white but would like to have it change to black for dark mode (as the text automatically changes and is unreadable with the white background). I cannot figure out how to do this.
Here is the rounded background xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#color/white" />
<corners android:radius="25dp" />
</shape>
Here is how I create my dialog:
var myDialog: Dialog
myDialog = Dialog(this.requireContext())
myDialog.setContentView(R.layout.popup_deposit);
myDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
myDialog.show()
R.layout.popup_deposit:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#drawable/rounded"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/textDepAmount"
android:layout_width="228dp"
android:layout_height="68dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:ems="100"
android:hint="0"
android:importantForAutofill="no"
android:inputType="number"
app:layout_constraintEnd_toStartOf="#+id/buttonDepAll"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<Button
android:id="#+id/buttonDepAll"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_marginEnd="10dp"
android:text="#string/all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/textDepAmount"
app:layout_constraintTop_toTopOf="#+id/textDepAmount" />
<TextView
android:id="#+id/textView4"
android:layout_width="244dp"
android:layout_height="49dp"
android:text="#string/how_much_money_would_you_like_to_deposit"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/buttonBack"
app:layout_constraintTop_toTopOf="#+id/buttonBack" />
<Button
android:id="#+id/buttonConfirmDeposit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="2dp"
android:enabled="false"
android:text="#string/deposit"
app:cornerRadius="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textDepAmount" />
<ImageButton
android:id="#+id/buttonBack"
android:layout_width="54dp"
android:layout_height="50dp"
android:layout_marginTop="16dp"
android:contentDescription="#string/back"
app:layout_constraintEnd_toStartOf="#+id/textView4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_arrow_back_black_24dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Does anybody know how to do this? Any answers would be appreciated

Add Lines around an Image

Here guys,
I would like to add 4 lines of View in my Android screen. I was able to add 2 Lines, one on the top and one on the left but I don't know how to add one on the right and one on the bottom.
Here is my XML Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
app:layout_constraintHeight_percent="0.25"
app:layout_constraintWidth_percent="0.25"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imvBalle"
android:layout_width="24dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.482"
app:srcCompat="#drawable/balle" />
<View
android:id="#+id/lineTop"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/darker_gray" />
<View
android:id="#+id/lineLeft"
android:layout_width="10dp"
android:layout_height="match_parent"
android:background="#android:color/darker_gray" />
</android.support.constraint.ConstraintLayout>
Use layout_constraintEnd_toEndOf and layout_constraintBottom_toBottomOf constraints:
<View
android:id="#+id/lineRight"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/darker_gray"
app:layout_constraintEnd_toEndOf="parent" />
<View
android:id="#+id/lineBottom"
android:layout_width="10dp"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent" />
You can add background around your view by creating a border shape.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle" >
<stroke
android:width="1dp"
android:color="#000000"
android:dashWidth="5dp"></stroke>
</shape>
</item>
</selector>

How do I prevent Views from sticking out of the rounded corner of a CardView?

Here's the XML:
<android.support.v7.widget.CardView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginBottom="24dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="24dp"
app:cardBackgroundColor="#android:color/white"
app:cardElevation="2dp" app:cardCornerRadius="16dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView10"
android:layout_weight="2"/>
<TextView
android:text="Bids"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView11"
android:layout_weight="1"
android:background="#ea6464"
android:gravity="center_vertical|center_horizontal"
android:textAllCaps="true"
android:textStyle="bold"
android:textColor="#android:color/white"/>
</LinearLayout>
</android.support.v7.widget.CardView>
And here's what it ends up looking like:
How do I tuck the TextView / LinearLayout under the corner so it doesn't stick out?
Like I said in the comments section.
You can create a drawable with rounded corners at the bottom, then set that as the background.
Here is the shape I called it rounded.xml:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#e56067"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
<corners android:radius="1dp"
android:bottomRightRadius="16dp"
android:bottomLeftRadius="16dp"/>
</shape>
Then change your layout to this:
<android.support.v7.widget.CardView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginBottom="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="16dp"
app:cardElevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="TextView" />
<TextView
android:id="#+id/textView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/rounded.xml"
android:gravity="center_vertical|center_horizontal"
android:text="Bids"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
The result will look like this:
You have to create drawable with the bottom rounded corner like below and set it in TextView background property:
shape_bottom_rounded_corner_red.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#ea6464" />
<corners
android:bottomLeftRadius="16dp"
android:bottomRightRadius="16dp" />
</shape>
Set android:background="#drawable/shape_bottom_rounded_corner_red" in your TextView:
<TextView
android:id="#+id/textView11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/shape_bottom_rounded_corner_red"
android:gravity="center_vertical|center_horizontal"
android:text="Bids"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textStyle="bold" />
Note: You have to set the same dimensions for bottomLeftRadius and bottomRightRadius in the drawable file which you have set in cardCornerRadius in CardView.

Categories

Resources