Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android rounded corner textview with perfect round in the corner

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

in the above (original) picture, the button 2's left and right rounded corner are correctly shaped but in my code the left and right rounded corners are not shaped correctly

enter image description here

in the second picture I need to do more rounded as the 1st image. how can I do with following drawable?

drawable 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" />
    ......
like image 700
M.A.Murali Avatar asked Dec 23 '15 18:12

M.A.Murali


2 Answers

create a file round.xml 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 textview like

<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" />

it should work

like image 80
Ram Mandal Avatar answered Dec 22 '22 00:12

Ram Mandal


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

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

enter image description here

like image 30
Nishant Srivastava Avatar answered Dec 22 '22 00:12

Nishant Srivastava