2011-08-04 81 views
0

其實我已經創建了一個標籤主機..現在,當我設置每個標籤的背景爲半透明比每一個標籤之間出現一條黑線..我發送我的代碼和快照來證明我answer..so請人建議我我如何才能解決這些問題的XML問題在製作標籤主機背景半透明

...代碼的Java

<?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>  

代碼..

//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) 

enter image description here

+0

您是否製作了自己的drawables?它們的尺寸不一樣嗎? – Jack

+0

你們他們是相同的大小 – AndroidDev

回答

1

我不確定這是否能解決問題,但值得一試,因爲看起來分頻器是導致問題的原因。

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

沒有它不工作.. – AndroidDev

+0

這是值得一試。我建議看看這個頁面 - http://joshclemm.com/blog/?p=136。我有很多麻煩讓我的標籤看起來像我想要的方式,並最終找到了這個網站。這將允許您自定義選項卡的每個方面並控制一切。 HTH – hooked82

+0

另外,造成黑線的原因是因爲兩個標籤疊在一起,兩張透明膠片看起來似乎有黑線。也許你有一些利潤率/填充物正在運行? – hooked82