Java 使FragmentTabHost的所有选项卡都适合屏幕
我正在开发一个android应用程序,带有标签(Java 使FragmentTabHost的所有选项卡都适合屏幕,java,android,Java,Android,我正在开发一个android应用程序,带有标签(FragmentTabHost)。 我有一个带有6个选项卡的片段活动。此时,选项卡的名称显示为正在跳行。我想所有的标签,以适应在屏幕的宽度,而不必做一个水平滚动视图。如何以良好的可视化效果显示选项卡名称。我怎样才能做到这一点?试试这样改变你的xml布局 <android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/androi
FragmentTabHost
)。
我有一个带有6个选项卡的
片段活动
。此时,选项卡的名称显示为正在跳行。我想所有的标签,以适应在屏幕的宽度,而不必做一个水平滚动视图。如何以良好的可视化效果显示选项卡名称。我怎样才能做到这一点?试试这样改变你的xml布局
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
hs.addView(tw);
hs.setHorizontalScrollBarEnabled(假) 我可以在不滚动的情况下输入选项卡:
for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
mTabHost.getTabWidget().getChildAt(i).setPadding(0, 0, 0, 0);
mTabHost.getTabWidget().getChildAt(i).setMinimumWidth(10);
}
for(int i=0;i
我没有使用tableyout,我使用的是片段
for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
mTabHost.getTabWidget().getChildAt(i).setPadding(0, 0, 0, 0);
mTabHost.getTabWidget().getChildAt(i).setMinimumWidth(10);
}