I have a RelativeLayout
containing 2 LinearLayouts
one of them is partially covering the other. I want to make the part of the LinearLayout
on top transparent so I can also see the 2nd LinearLayout
knowing that i have 2 images as background for the 2 LinearLayouts
.
getBackground(). setAlpha(51); Here you can set the opacity between 0 (fully transparent) to 255 (completely opaque). The 51 is exactly the 20% you want.
When we set the color it is like ARGB(Alpha Red Green Blue). You need to change the alpha in the color code to increase or decrease the amount of Transparency :
You can range it from 00 to FF (Hexa Decimal)
For maximum transparency => #00555555 (Here 00 stands for the alpha)
For minimum or no transparency => #FF555555 (Here FF stands for the alpha)
So, for setting the transparency of an ImageView you can code like this:
ImageView image = (ImageView) findViewById(R.id.myImage); image.setAlpha(0.3);
Also, you can set the alpha for your LinearLayout like this :
LinearLayout ll = (LinearLayout) findViewById(R.id.linearlayout); ll.setAlpha(0.4);
Use this in your Layout
android:alpha="0.5"
0.0 is totally transparent, 1.0 is fully opaque.
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