Android rounded corner text with perfect round corner

How to show a text image with a rounded corner rectangle as shown in the original image enter image description here

in the above (original) image, the button 2 of the left and right rounded corners has the correct shape, but in my code the left and right rounded corners do not have the correct shape

enter image description here

in the second shot I need to do more rounded as the first image. how can i do using drawable?

extractable code (green_bg.xml)

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#19D8C8" /> <corners android:radius="3dip" /> <stroke android:width="10dp" android:color="#19D8C8" /> </shape> 

activity_main.xml

 ....... <TextView android:id="@+id/qmap_2" android:layout_width="35dp" android:layout_height="24dp" android:layout_gravity="center_vertical" android:gravity="center" android:text="2" android:textStyle="bold" android:textColor="@color/no_color" /> ...... 
+5
source share
2 answers

create a round.xml file in drawable

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#176d7a" /> <corners android:radius="50dp" /> </shape> 

now set the background of the text view, for example

 <TextView android:id="@+id/qmap_2" android:layout_width="35dp" android:layout_height="24dp" android:layout_gravity="center_vertical" android:gravity="center" android:text="2" android:textStyle="bold" android:background="@drawable/round" android:textColor="@color/no_color" /> 

he should work

+4
source

Change the radius angle to a much higher value i.e. 100dp

 <corners android:radius="100dip" /> 

enter image description here

+1
source

Source: https://habr.com/ru/post/1239077/


All Articles