[英]How to resize actionbar tabs
I looked all stackoverflow's topics about it, and none of these solutions - like this one: 我查看了所有关于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
that changed nothing - (none of these) helped me. 那什么都没变-(这些都没有)帮助了我。
I have 5 tabs, without title, just icon, but I need it to be all visible at the same time, so it have to be small to fit all. 我有5个标签,没有标题,只有图标,但是我需要同时显示所有标签,因此它必须很小以适合所有人。 How can I make the tab has that size?
如何使标签具有该大小?
Change the height of your ActionBar
to change your tabs size: 更改
ActionBar
的高度以更改标签的大小:
<item name="android:actionBarSize">#dp</item>
Hope this helps. 希望这可以帮助。
EDIT: 编辑:
Maybe you can customize a TabBar yourself with ImageViews
, see below: 也许您可以使用
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 -->
And in your Activity
, you can make a NavListener
: 在
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;
// ...
}
}
};
Hope this helpful. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.