Search code examples
androidxmldrawable

Setting alpha on a BitmapDrawable in XML


I was wondering if its possible to set transparency in XML for a Drawable. In this case its setting the disabled state of a button. Instead of using a separate image i should like to create a grayed-out version by changing the alpha. I know I could do that in code. But can it also be predefined in XML?


Solution

  • Since: API Level 11 it is possible for View. but if we are talking about ImageView there is a tint attribute ans it's since API Level 1.

    http://developer.android.com/reference/android/widget/ImageView.html#attr_android:tint

    http://developer.android.com/reference/android/view/View.html#attr_android:alpha