drawable
How to reset AnimationDrawable
This will send the (AnimationDrawable) timerAnimation to the first frame as soon as stop() has been called: timerAnimation.stop(); timerAnimation.selectDrawable(0);
Access resource defined in theme and attrs.xml android
I think you can get the Drawable with this code: TypedArray a = getTheme().obtainStyledAttributes(R.style.AppTheme, new int[] {R.attr.homeIcon}); int attributeResourceId = a.getResourceId(0, 0); Drawable drawable = getResources().getDrawable(attributeResourceId); a.recycle();
Deep copy of a Drawable
Finally I succeed! I had similar problem, when I used color filter on my drawable it changed the drawable, its very close to the solution of the other people here, but only this worked for me: Drawable drwNewCopy = dr.getConstantState().newDrawable().mutate();
How to draw text on canvas?
You will have to use the drawText method of the Canvas class. Paint paint = new Paint(); canvas.drawPaint(paint); paint.setColor(Color.BLACK); paint.setTextSize(16); canvas.drawText(“My Text”, x, y, paint); Here’s the relevant documentation about it: http://developer.android.com/reference/android/graphics/Canvas.html#drawText(java.lang.String, float, float, android.graphics.Paint)
How to set an empty drawable
You can use a transparent ColorDrawable: Drawable transparentDrawable = new ColorDrawable(Color.TRANSPARENT); That’s a Drawable that represents the transparent color and doesn’t have an intrinsic size.
How to set drawable size in layer-list
You can use android:width and android:height parameters with desired values. Below is the sample drawable layer-list and screen shot. I used the vector drawable from google material icons and own selector drawable. Original circle.xml drawable shape have 100dp x 100dp size, but into drawable.xml I override this values to 24dp x 24dp by android:width and … Read more
DrawableCompat tinting does not work on pre-Lollipop
When you call wrap() then the original Drawable is wrapped internally into a new DrawableWrapper which is used to implement the tinting on older devices. So to make it work you have to set the returned Drawable back to the EditText: final Drawable originalDrawable = editText.getBackground(); final Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable); DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(Color.RED)); editText.setBackground(wrappedDrawable); Since … Read more