I have created a layout so that the border is set with a drawable
with round corners. When I set the background for a text view inside this layout, the corner becomes sharp.
Here is my XML looks like.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/det_event_time"
android:layout_marginTop="50dp"
android:id="@+id/det_action_buttons"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:background="@drawable/detail_approval_round"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Approve"
android:padding="10dp"
android:textAlignment="center"
android:textColor="@android:color/black"
android:layout_weight="1"
android:id="@+id/det_action_approve"/>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@color/violet"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Reject"
android:layout_weight="1"
android:textAlignment="center"
android:textColor="@android:color/black"
android:padding="10dp"
android:id="@+id/det_action_reject"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1px"
android:background="@color/violet"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Cancel"
android:padding="10dp"
android:textColor="@android:color/black"
android:textAlignment="center"
android:layout_weight="1"
android:id="@+id/det_action_cancel"/>
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@color/violet"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Pending"
android:layout_weight="1"
android:background="@color/violet"
android:textColor="@android:color/white"
android:textAlignment="center"
android:padding="10dp"
android:id="@+id/det_action_pending"/>
</LinearLayout>
</LinearLayout>
The output I am getting is like below
Can anyone help me to make the bottom right corner as round when I set the background for the TextViews? Can we do this without using drawable for each TextView?
You could use a background.xml file with radius at bottom right corner.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:bottomRightRadius="10dp" />
<solid android:color="#444444" />
</shape>
</item>
</selector>
And set the Textview background.
<TextView
...
android:background="@drawable/background"
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.