Android : Get drawables that make up an EditText?

on Thursday, January 29, 2015


Is there a way to get the drawable resources that make up an EditText?


Specifically I'd like to know the drawables that make up the focused and non focused states.


I thought the EditText background was a StateListDrawable, then I could grab out the selected resources, but when examining, it is a "TintDrawableWrapper":



EditText et = ...;
Log.v(TAG, "Background: " + et.getBackground());

// prints:
android.support.v7.internal.widget.TintDrawableWrapper


so there's not much documentation on that class, or if it's even the same on all platforms.


Separately I was looking at other posts if the drawables had names, like:



@android:drawable/editbox_background_normal


but these look like old styles assets that don't match.


Any ideas on how I could get those assets? I've considered creating an off-screen EditText, then drawing it to a bitmap, but to get the focused drawable state, I would have to have the EditText request focus, which would probably pop the keyboard up etc and cause all kinds of problems.


Thanks


0 comments:

Post a Comment