Search code examples
androidandroid-edittext

How to change style of a default EditText


I am creating three EditTexts in my xml file using code like this:

<EditText
    android:id="@+id/name_edit_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/profile_image_view_layout"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="20dp"
    android:ems="15"
    android:hint="@string/name_field"
    android:inputType="text" />

When I run the app, it looks like this on my device:

enter image description here

But I want it to look like this, without using any background image:

enter image description here

So how can that be done? Any ideas or suggestions will be helpful.


Solution

  • You have a few options.

    1. Use Android assets studios Android Holo colors generator to generate the resources, styles and themes you need to add to your app to get the holo look across all devices.

    2. Use holo everywhere library.

    3. Use the PNG for the holo text fields and set them as background images yourself. You can get the images from the Android assets studios holo color generator. You'll have to make a drawable and define the normal, selected and disabled states.

    UPDATE 2016-01-07

    This answer is now outdated. Android has tinting API and ability to theme on controls directly now. A good reference for how to style or theme any element is a site called materialdoc.