How To Create And Use Custom Shape in Android Drawable

One of the beauties of the Android resource system is that the background of any view like Button, TextView, ListView and other views, can be a Drawable an XML File. Drawables can be images, colors, transitions, shapes, gradient, border, corner and a variety of other powerful sources. It is often possible to create a really nice looking background images just by using Shape Drawables. Shape Drawables are XML declarations of a graphical shape which is interpreted at run-time by the Android system and rendered as a graphic.

It's very simple to create and used shape in android drawable. First create new android project and make new folder under res folder called drawable res/drawable. Create new xml file you give name as your needed.

btn_shape_rectangle.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <shape xmlns:android="http://schemas.android.com/apk/res/android"   
   android:shape="rectangle">  
   <solid android:color="#4f67da"/>  
 </shape>  

btn_shape_oval.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <shape xmlns:android="http://schemas.android.com/apk/res/android"   
   android:shape="oval">  
   <solid android:color="#4f67da"/>  
 </shape>  

Comments

Popular posts from this blog

Tutorial Integration Firebase With Admob on Android

Firebase Configuration in Android

How To Generate A Random String Alphabet And Number in Java Android