如何在android中使linearLayout部分透明? [英] How to make a linearLayout partially transparent in android?
问题描述
我有一个包含2个LinearLayouts
的RelativeLayout
,其中一个部分覆盖了另一个.我想使顶部的LinearLayout
部分透明,因此我也可以看到第二个LinearLayout
,因为我知道有2个图像作为2个LinearLayouts
的背景.
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
.
推荐答案
设置颜色后,它就像 ARGB(Alpha Red Green Blue).您需要 更改颜色代码中的字母以增加或减少透明度 :
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 :
您可以将其设置为00到FF(十六进制十进制)
为获得最大透明度=> #00555555(此处 00 表示Alpha)
For maximum transparency => #00555555 (Here 00 stands for the alpha)
对于最低透明度或无透明度=> #FF555555(此处 FF 表示Alpha)
For minimum or no transparency => #FF555555 (Here FF stands for the alpha)
因此,用于设置 ImageView的透明度,您可以这样编写代码:
So, for setting the transparency of an ImageView you can code like this:
ImageView image = (ImageView) findViewById(R.id.myImage);
image.setAlpha(0.3);
此外,您可以像这样为 LinearLayout 设置Alpha :
Also, you can set the alpha for your LinearLayout like this :
LinearLayout ll = (LinearLayout) findViewById(R.id.linearlayout);
ll.setAlpha(0.4);
这篇关于如何在android中使linearLayout部分透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!