其实我已经创建了一个标签主机..现在当我将每个标签的背景设置为半透明而不是每个标签之间出现一条暗线时..我正在发送我的代码和快照以证明我的答案。所以任何人都请建议我如何解决这些问题
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>
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)
答案 0 :(得分:1)
我不确定这是否会解决它,但它值得一试,因为它看起来像分隔符是导致问题的原因。
tabHost.getTabWidget().setDividerDrawable(null);