[英]how to set transparent background to android tab widget,
Is it possible to set a transparent background to android tab widget,I used the below code to set the tab background image 是否可以为android选项卡小部件设置透明背景,我使用以下代码设置选项卡背景图像
Drawable drawable = new BitmapDrawable(bgImage);
mTabHost.getTabWidget().setBackgroundDrawable(drawable);
but the problem,is i can see a black line not a transparent, can someone help me on to fix this..! 但是问题是我能看到黑线不是透明的,有人可以帮我解决这个问题吗!
There are two things you need to know here. 您需要在这里了解两件事。
First, you set a background programmatically with 首先,您可以通过编程方式设置背景
Second, you set transparency with the alpha channel of a hex value. 其次,使用十六进制值的Alpha通道设置透明度。 Eg.
例如。 if you want to set your background to red with 20% transparency, you would use the hex value
#CCFF0000
. 如果要将背景设置为红色且透明度为20%,则可以使用十六进制值
#CCFF0000
。 In this example, CC is the hex number for 255 * 0.8 = 204. 在此示例中,CC是255 * 0.8 = 204的十六进制数。
I'm a little confused as to what you're trying to achieve here as I can't tell whether drawable
is created from an XML file or from an image file. 对于您在此处要实现的目标,我有些困惑,因为我无法确定
drawable
是从XML文件还是从图像文件创建的。 If bgImage is an XML file, however, you should be able to solve your problem by applying the type of hex value I described above to the appropriate area of your XML file with android:background=""
但是,如果bgImage是XML文件,则可以使用
android:background=""
将上述的十六进制值类型应用于XML文件的适当区域,从而解决问题。
create a transparent png image, just a blank image. 创建一个透明的png图像,只是一个空白图像。 Make this image the background for the bar.
将此图像作为酒吧的背景。
mTabHost.getTabWidget().setBackgroundDrawable(R.id.mytransperentimage);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.