我有一个带有 3 个选项卡的操作栏。它看起来像这样:| 全部 | 来电 | 网络 | 我希望它们具有相同的宽度。我该怎么做?
问问题
3711 次
3 回答
2
您可以使用 ActionBar.Tab 上的 setCustomView() 方法为任何视图设置标签。我就是这样做的。自定义视图是从一个布局加载的,在我的例子中,该布局类似于 ActionBar.Tag 使用的内置布局,您可以根据需要设置边距、大小和内容。
于 2012-02-02T15:55:02.003 回答
0
它们都以相同的宽度在行中对齐
<?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">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</HorizontalScrollView>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
</TabHost>
然后将选项卡主机设置为
TabHost tabHost;
TabHost.TabSpec spec;
tabHost=getTabHost()
Intent intent;
intent=new Intent().setClass(this, BirthDayTab.class);
spec=tabHost.newTabSpec("artists").setIndicator("BirthDay",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);
tabHost.addTab(spec);
于 2012-02-02T12:52:27.270 回答
-1
https://groups.google.com/forum/#!topic/actionbarsherlock/4oT9KwhB0O8 这是我几天来一直在寻找的确切解决方案
于 2014-07-14T12:51:41.387 回答