我查看了有关它的所有stackoverflow主题,而没有这些解决方案 - 就像这一个:
<style name="Widget.Holo.Tab" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:height">#dp</item>
</style>
<style name="Your.Theme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarTabStyle">@style/Widget.Holo.Tab</item>
</style>
http://stackoverflow.com/questions/9286638/actionbar-tabs-height
没有改变 - (这些都没有)帮助过我。
我有5个标签,没有标题,只有图标,但我需要它同时全部可见,所以它必须小才适合所有。如何使标签具有该大小?
答案 0 :(得分:0)
更改ActionBar
的高度以更改标签尺寸:
<item name="android:actionBarSize">#dp</item>
希望这有帮助。
编辑:
也许您可以使用ImageViews
自行自定义 TabBar ,请参阅以下内容:
<!-- Tab Nav -->
<TableLayout
android:id="@+id/TabNavMain"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dip"
android:stretchColumns="5" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_horizontal"
android:weightSum="5">
<ImageView
android:id="@+id/TabNav1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onNavSelected"
android:clickable="true" />
<ImageView
android:id="@+id/TabNav2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onNavSelected"
android:clickable="true" />
<ImageView
android:id="@+id/TabNav3"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onNavSelected"
android:clickable="true" />
<ImageView
android:id="@+id/TabNav4"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onNavSelected"
android:clickable="true" />
<ImageView
android:id="@+id/TabNav5"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onNavSelected"
android:clickable="true" />
</TableRow>
</TableLayout>
<!-- End Tab Nav -->
在您的Activity
中,您可以制作NavListener
:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
NavListener navListener = new NavListener();
}
private class NavListener implements View.OnClickListener {
@Override
public void onNavSelected(View v) {
switch (v.getId()) {
case R.id.TabNav1:
// do something...
break;
case R.id.TabNav2:
// do something else...
break;
case R.id.TabNav3:
// do something...
break;
// ...
}
}
};
希望这有用。