Opacity on a background Drawable image in View (using XML Layout) Opacity on a background Drawable image in View (using XML Layout) android android

Opacity on a background Drawable image in View (using XML Layout)


I ended up just going with the programmatical solution, since it doesn't look like it can be done via the XML layouts.

Drawable rightArrow = getResources().getDrawable(R.drawable.green_arrow_right_small);// setting the opacity (alpha)rightArrow.setAlpha(10);// setting the images on the ImageViewsrightImage.setImageDrawable(rightArrow);


This might make your Work simpler

View backgroundimage = findViewById(R.id.background);Drawable background = backgroundimage.getBackground();background.setAlpha(80);

Alpha Values 0-255, 0 means fully transparent, and 255 means fully opaque

from: This Answer


You can also use XML to change the transparency:

android:alpha = "0.7"

The value of alpha ranges from 0 to 1