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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With