Android – Change background color of edittext in android

android, android-edittext, android-layout

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:

Image of EditText

Best Solution

one line of lazy code:

mEditText.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);