If I change the background color of my EditText
using the below code, it looks like the box is shrunken and it doesn't maintain the ICS theme of a blue bottom border that exists for a default EditText
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#99000000"
>
<EditText
android:id="@+id/id_nick_name"
android:layout_marginTop="80dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:orientation="horizontal"
android:layout_below="@+id/id_nick_name">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="add"
android:layout_weight="1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cancel"
android:layout_weight="1"
/>
</LinearLayout>
</RelativeLayout>
Here is what it looks like:
one line of lazy code:
mEditText.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
Here the best way
First : make new xml
file in res
/drawable
name it rounded_edit_text
then paste this:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#F9966B" />
<corners
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
</shape>
Second: in res/layout copy and past following code (code of EditText
)
<EditText
android:id="@+id/txtdoctor"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/rounded_edit_text"
android:ems="10" >
<requestFocus />
</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