4

I had try below snippet but its not working for below API 21:

editText.getBackground().setColorFilter(editTextColor, PorterDuff.Mode.SRC_IN);
editText.getBackground().mutate().setColorFilter(editTextColor,PorterDuff.Mode.SRC_ATOP);

So please suggest me how can I Change for API 14.

earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Ronit kadwane
  • 524
  • 1
  • 5
  • 22

2 Answers2

5

Use this:

Drawable drawable = editText.getBackground();
drawable.setColorFilter(editTextColor, PorterDuff.Mode.SRC_ATOP);
if(Build.VERSION.SDK_INT > 16) {
    editText.setBackground(drawable);
}else{
    editText.setBackgroundDrawable(drawable);
}
Michele Lacorte
  • 5,323
  • 7
  • 32
  • 54
0

Setting the android:textCursorDrawable attribute to @null should result in the use of android:textColor as the cursor color.

Attribute textCursorDrawable is available in API level 12 and higher.

Konrad Morawski
  • 8,307
  • 7
  • 53
  • 91