I have put an image in as the background of my android application with the following line of code:
android:background=\"@drawable/background\"
You can set the alpha property:
android:alpha="0.4"
via code :
yourView.setAlpha(0.5f);
only the background :
yourView.getBackground().setAlpha(120); // here the value is an integer not float
just use this line in your .xml file
android:background="#ddxxxxxx"
replace the xxxxxx with any color you want.
refer https://alvinalexander.com/android/how-background-image-behind-translucent-opaque-textview for more details.
you can create a layer-list resource and set it to background property of your view (layout)
background_image_with_alpha.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:alpha="0.2"
android:src="@drawable/xxxxxx"
android:gravity="fill">
</bitmap>
</item>
</layer-list >