fragmenttabhost.xml是
<android.support.v4.app.FragmentTabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_weight="0"
android:layout_height="110dp"
android:showDividers="middle"
android:divider="@drawable/tab_divider"
android:layout_marginBottom="0dp" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
和 tab_divider.xml 是
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<size
android:height="100px"
android:width="1dp" />
<solid android:color="@color/red" />
</shape>
任何帮助都会非常值得注意。 感谢。
答案 0 :(得分:0)
您可以以这种方式明确添加分隔符
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView dividerImage = new ImageView(this);
dividerImage.setImageResource(R.drawable.tab_seperator);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, Page1.class);
spec = tabHost.newTabSpec("page1").setIndicator(getLayoutInflater().inflate(R.layout.tab1, null))
.setContent(intent);
tabHost.addTab(spec);
tabHost.getTabWidget().addView(dividerImage, LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
intent = new Intent().setClass(this, Page2.class);
spec = tabHost.newTabSpec("page2").setIndicator(getLayoutInflater().inflate(R.layout.tab2, null))
.setContent(intent);
tabHost.addTab(spec);
}