Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of icon which is placed inside edittext?

I am developing an application which has multiple form, but i want some effects on it. What i want to do is changing the color of icon which is placed inside edit text.

<EditText
    android:id="@+id/marks"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/button1"
    android:layout_alignParentTop="true"
    android:layout_marginTop="10dp"
    android:drawableRight="@drawable/ic_border"
    android:hint="Total Marks"
    android:inputType="number"
    android:textColor="#fff" />
like image 331
Kriti Jain Avatar asked Oct 19 '22 08:10

Kriti Jain


1 Answers

if you want to change the color you can use this
first change the color of the drawable.

Drawable mDrawable = context.getResources().getDrawable(R.drawable.yourdrawable); 
mDrawable.setColorFilter(new 
PorterDuffColorFilter(0xffff00,PorterDuff.Mode.MULTIPLY));

now set it to the EditText

edtText.setCompoundDrawablesWithIntrinsicBounds(mDrawable, 0, 0, 0);
like image 63
Devendra Singh Avatar answered Oct 21 '22 05:10

Devendra Singh