Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regarding edit text complete border

I am new to android. I was creating one sample page in which I need to give the background of page as white. but then, if not focused my edit text was not visible with white background. How could I add border of desired color to my edit text so that it become visible. Apart from that when ever I was pressing enter in edit text box it was adding a new line to it. I want to remove this also. Can any body help me out in this. Thanks in advance

like image 933
Android Avatar asked Feb 24 '12 06:02

Android


1 Answers

You can set a drawable for your edittext.

edittext_bg.xml:(put this file in your drawable folder)

<?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>

then set your edittext's background as android:background="@drawable/edittext_bg". But this will remove all default background effect of edittext.You can make a selector for edittext for giving it different background when it is in selected state or normal state.

And you can set android:singleLine="true" in your edittext tag to prevent it to have multiline in edittext.

like image 126
Hiral Vadodaria Avatar answered Oct 04 '22 03:10

Hiral Vadodaria