Rounded corner for textview in android

Create rounded_corner.xml in the drawable folder and add the following content, <?xml version=”1.0″ encoding=”utf-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android” > <stroke android:width=”1dp” android:color=”@color/common_border_color” /> <solid android:color=”#ffffff” /> <padding android:left=”1dp” android:right=”1dp” android:bottom=”1dp” android:top=”1dp” /> <corners android:radius=”5dp” /> </shape> Set this drawable in the TextView background property like so: android:background=”@drawable/rounded_corner” I hope this is useful for you.

Android: Drawing custom shapes

Try the following shape drawable xml: <?xml version=”1.0″ encoding=”UTF-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <!– Colored rectangle–> <item> <shape android:shape=”rectangle”> <size android:width=”100dp” android:height=”40dp” /> <solid android:color=”#FAD55C” /> </shape> </item> <!– This rectangle for the left side –> <!– Its color should be the same as layout’s –> <item android:right=”90dp” android:left=”-30dp”> <rotate android:fromDegrees=”45″> <shape android:shape=”rectangle”> <solid android:color=”#ffffff” /> … Read more

How to create EditText with rounded corners?

There is an easier way than the one written by CommonsWare. Just create a drawable resource that specifies the way the EditText will be drawn: <?xml version=”1.0″ encoding=”utf-8″?> <!– res/drawable/rounded_edittext.xml –> <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle” android:padding=”10dp”> <solid android:color=”#FFFFFF” /> <corners android:bottomRightRadius=”15dp” android:bottomLeftRadius=”15dp” android:topLeftRadius=”15dp” android:topRightRadius=”15dp” /> </shape> Then, just reference this drawable in your layout: <?xml version=”1.0″ … Read more

How to put a border around an Android TextView?

You can set a shape drawable (a rectangle) as background for the view. <TextView android:text=”Some text” android:background=”@drawable/back”/> And rectangle drawable back.xml (put into res/drawable folder): <shape xmlns:android=”http://schemas.android.com/apk/res/android” android:shape=”rectangle” > <solid android:color=”@android:color/white” /> <stroke android:width=”1dip” android:color=”#4fa5d5″/> </shape> You can use @android:color/transparent for the solid color to have a transparent background. You can also use padding to … Read more

How to make layout with rounded corners..?

1: Define layout_bg.xml in drawables: <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <solid android:color=”#FFFFFF”/> <stroke android:width=”3dp” android:color=”#B1BCBE” /> <corners android:radius=”10dp”/> <padding android:left=”0dp” android:top=”0dp” android:right=”0dp” android:bottom=”0dp” /> </shape> 2: Add layout_bg.xml as background to your layout android:background=”@drawable/layout_bg”