Reputation: 1168
I'm new to android application.
In this picture,there is a bottom layout with some options like play,delete etc.., and has its transparency to show its background.
How to I get like that ?
Upvotes: 19
Views: 46530
Reputation: 874
It's also incredibly easy to just set the alpha value, one of two ways. My example applies a 60% opaque black background to a linear layout.
The first method is to add the following line to change the alpha of the layout in the XML file (also in image):
android:background="@android:color/black"
android:alpha="0.6"
The second method is to change the alpha and background values in the design editor view:
Upvotes: 6
Reputation: 1084
use android:background ="#88676767"
change the first 88 to your selection of opacity
In reply to your comment:
ImageView iv = (ImageView) findViewById(your_imageId);
iv.setColorFilter(Color.argb(150, 155, 155, 155), Mode.SRC_ATOP);
Third option:
LinearLayout layout = (LinearLayout) findViewById(R.id.your_id);
Drawable d = getResources().getDrawable(R.relevant_drawable);
d.setAlpha(50);
layout.setBackgroundDrawable(d);
Upvotes: 57
Reputation: 7027
The color format is ARGB, which means ALPHA/RED/GREEN/BLUE.
The transparency is set on the alpha channel, a value of 0 (0x00) is completely transparent and a value of 255 (0xFF) is completely opaque.
So if you need a grayish color half transparent, then set this color: #80444444
Upvotes: 17
Reputation: 6667
Refer these links:
1.How to Set Opacity (Alpha) for View in Android
2. Android: how to create transparent or opeque background
Upvotes: 3
Reputation: 4511
Use 32-bit PNG with transparency for your background (in that particular case, cause it does not have uniform transparency)
Upvotes: 1