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 ?
Changing the opacity of the background color only To achieve this, use a color value which has an alpha channel—such as rgba. As with opacity , a value of 1 for the alpha channel value makes the color fully opaque. Therefore background-color: rgba(0,0,0,. 5); will set the background color to 50% opacity.
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);
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
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With