开发者

Problem in making tab host background translucent

I have created a tab host. Now when I set the background of each tab as translucent than a dark line appears between each tab. I am sending my code and snapshot to justify my answer. So anyone, please suggest to me how I can resolve this problem.

Code for XML

<?xml version="1.0" encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
    android:id="@android:id/tabs"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
    <FrameLayout
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />
    </LinearLayout>
</TabHost>      

Code for java

//create tabs
                Resources res = getResources(); 
                final TabHost MainTabHost = getTabHost();  
                TabHost.TabSpec spec; 
                Intent intent; 
                
                MainTabHost.getTabWidget().setStripEnabled(false);
                
                //call calendar Activity class
                intent = new Intent().setClass(this, CalendarForm.class);
                //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost1)).setIndicator("Calendar",
                res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
                
                MainTabHost.addTab(spec);
                
                //call History Activity class
                intent = new Intent().setClass(this, HistoryForm.class);
               // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost2)).setIndicator("History",
                res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
                MainTabHost.addTab(spec);
        
                //call Statistic Activity class
                intent = new Intent().setClass(this, StatisticForm.class);
                //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                spec = MainTabHost.newTabSpec(res.getString(R.string.text_tabHost3)).setIndicator("Statistic",
                res.getDrawable(R.drawable.calendar_ic)).setContent(intent);
                MainTabHost.addTab(spec);
                
                //setbackground Style of tabHost                                       
                MainTabHost.setCurrentTab(0); 
                MainTabHost.getTabWidget().setWeightSum(3);
                final TabWidget tabHost=getTabWidget();   
                MainTabHost.setBackgroundResource(R.drawable.back_image);

               //set background translucent..                       
                MainTabHost.getTabWidget().getChildAt(0)setBackground(#50000000);
      开发者_开发问答          MainTabHost.getTabWidget().getChildAt(1).setBackground(#50000000)
                MainTabHost.getTabWidget().getChildAt(2).setBackground(#50000000)

Problem in making tab host background translucent


I'm not sure if this will solve it, but it's worth a shot as it looks like the divider is what's causing the issue.

tabHost.getTabWidget().setDividerDrawable(null);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜