2011-08-04 11 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

あなた自身のドロウアブルを作成しましたか?彼らは同じサイズではありませんか? – Jack

+0

yeh彼らは同じサイズです – AndroidDev

答えて

1

これで解決できるかどうかはわかりませんが、問題の原因は分周器のように見えます。

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

いいえ、それは働いていません.. – AndroidDev

+0

それはショットの価値があった。私はこのページを見てみることをお勧めします - http://joshclemm.com/blog/?p=136。私は、私が望むやり方を見て私のタブを得るのに苦労して、このサイトを見つけました。これにより、タブのすべての側面をカスタマイズし、すべてを制御することができます。 HTH – hooked82

+0

また、その暗い線の理由は、2つのタブがお互いの上に重なり、2つの透明シートが一緒になって暗い線があるように見えるからです。たぶんあなたはいくつかのマージン/パディングがありますが、これはうまく動いていますか? – hooked82