Is it possible to set a transparent background to android tab widget,I used the below code to set the tab background image
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. Eg. if you want to set your background to red with 20% transparency, you would use the hex value #CCFF0000
. In this example, CC is the hex number for 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. 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=""
create a transparent png image, just a blank image. Make this image the background for the bar.
mTabHost.getTabWidget().setBackgroundDrawable(R.id.mytransperentimage);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.