I want to change the color of EditText Color and width programmatically for all Edit Text used in the project based on the app theme selected.
So I can't do this using XML and need a programatic solution.
So I want to create a custom function to set this
void setEditTextColorDrawable(int ClrVar)
{
// Code Todo
}
I tried all the methods suggested in
set textCursorDrawable programmatically
The issue is, getDeclaredField("mCursorDrawableRes") is not available above API22.
So how do I do this for all API even above 22
try {
// https://github.com/android/platform_frameworks_base/blob/kitkat-release/core/java/android/widget/TextView.java#L562-564
Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
f.setAccessible(true);
f.set(yourEditText, R.drawable.cursor);
} catch (Exception ignored)
{
log.d("TAG", "This is depricated")
}
Output : "This is depricated"