jason
jason

Reputation: 3962

change backgroundcolor of text in edittext

I have an edittext box and I would like to change the background color of text in edittext and not edittext background color.Basically there will be 2 background color in the end both edittext background color and textbackground color.How can add textbackground color to edittext?

<EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/editText"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"

        android:textColor="@android:color/white"
        />

Upvotes: 0

Views: 85

Answers (2)

Sheena Gupta
Sheena Gupta

Reputation: 59

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"

    <!---------------just add these two lines---------------------------->
    android:textColor="@android:color/white"`      
    android:background="@android:color/blue"`

/>

Upvotes: 1

Piotr Golinski
Piotr Golinski

Reputation: 1000

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#F00">

    <EditText
        android:id="@+id/editText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_margin="5dp"
        android:background="#0F0"
        android:minWidth="50dp"
        android:textColor="@android:color/white" />
</FrameLayout>

Upvotes: 2

Related Questions