Rapid Subscribe Android App

Rapid Subscribe Android App
Rapid Subscriber

Recent Posts

Rounded Corner Edit text in Android



In Android, Designing is a must to attract users to your app.

But in Android default coding, button shapes are sometimes not so attractive to see in your app.

So, We create an XML file to change the design of an EditText in Android.

1. Firstly we create a Drawable Resource File,

 For that, right click on Drawable folder -> New -> Drawable Resource file.

Give it a name of your choice. We name it roundedcorner.xml

2.  Add Code to it

 <?xml version="1.0" encoding="utf-8"?>  
 <!-- res/drawable/edittext_rounded_corners.xml -->  
 <selector xmlns:android="http://schemas.android.com/apk/res/android">  
   
   <item android:state_pressed="true" android:state_focused="true">  
     <shape>  
       <solid android:color="#FF8000"/>  
       <stroke  
         android:width="2.3dp"  
         android:color="#FF8000" />  
       <corners  
         android:radius="15dp" />  
     </shape>  
   </item>  
   
   <item android:state_pressed="true" android:state_focused="false">  
     <shape>  
       <solid android:color="#FF8000"/>  
       <stroke  
         android:width="2.3dp"  
         android:color="#FF8000" />  
       <corners  
         android:radius="15dp" />  
     </shape>  
   </item>  
   
   <item android:state_pressed="false" android:state_focused="true">  
     <shape>  
       <solid android:color="@color/black_overlay"/>  
       <stroke  
         android:width="2.3dp"  
         android:color="#FF8000" />  
       <corners  
         android:radius="15dp" />  
     </shape>  
   </item>  
   
   <item android:state_pressed="false" android:state_focused="false">  
     <shape>  
       <gradient  
         android:startColor="@color/black_overlay"  
         android:centerColor="@color/black_overlay"  
         android:endColor="@color/black_overlay"  
         android:angle="270"  
         />  
       <stroke  
         android:width="0.7dp"  
         android:color="#BDBDBD" />  
       <corners  
         android:radius="15dp" />  
     </shape>  
   </item>  
   
   <item android:state_enabled="true">  
     <shape>  
       <padding  
         android:left="4dp"  
         android:top="4dp"  
         android:right="4dp"  
         android:bottom="4dp"  
         />  
     </shape>  
   </item>  
   
 </selector>  

Change color as your choice.

3. Then in your EditText in XML,

Set Drawable Background as roundedcorner.


Colors.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <resources>  
   <color name="colorPrimary">#a7bffa</color>  
   <color name="colorPrimaryDark">#303f9f</color>  
   <color name="colorAccent">#FF4081</color>  
   
   <color name="black_overlay">#66000000</color>  
   
   
   <color name="black_semi_transparent">#B2000000</color>  
   <color name="background">#e5e5e5</color>  
   <color name="half_black">#000000</color>  
   <color name="white">#fafafa</color>  
   <color name="white_pressed">#f1f1f1</color>  
   <color name="pink">#e91e63</color>  
   <color name="pink_pressed">#ec407a</color>  
   <color name="blue_semi_transparent">#B805677F</color>  
   <color name="black_semi_transparent_pressed">#80738f</color>  
 </resources>  
   

Follow us for more posts like this, 
Subscribe Harpreet studio on Youtube  
Like Harpreet Studio on Facebook  
Follow me on Instagram 

No comments