Tech tip of this week

Android: Edit Text border line

To add border line to EditText, we have to set background drawable to EditText.
Below code, we have to keep it in drawable folder.

edittext_bg.xml

<?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="#000000" /> 
           <padding android:left="2dp" android:top="2dp" android:right="2dp"                   android:bottom="2dp" /> 
</shape>

We need to set above file to EditText view to show borderline.

<EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:hint="Write message here..."
             android:layout_marginLeft="16dip"
             android:layout_marginTop="2dip"
             android:background="@drawable/edittext_bg"
             android:layout_marginRight="12dip"
             android:textColor="@android:color/black"
             android:textSize="14dip" />

No comments:

Post a Comment