如何调整动作条的标签 [英] How to resize actionbar tabs
本文介绍了如何调整动作条的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看了所有的计算器的话题吧,而且这些解决方案 - 像这样的:
I looked all stackoverflow's topics about it, and none of these solutions - like this one:
<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.
我有5个标签,无标题,只是图标,但我需要它是所有可见在同一时间,所以它必须要小,适合所有。我怎样才能使标签具有尺寸?
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. How can I make the tab has that size?
推荐答案
变化的高度你的动作条
更改标签尺寸:
Change the height of your ActionBar
to change your tabs size:
<item name="android:actionBarSize">#dp</item>
希望这有助于。
Hope this helps.
编辑:
也许你可以自定义的的TabBar 的自己与 ImageViews
,见下图:
Maybe you can customize a TabBar yourself with ImageViews
, see below:
<!-- 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 -->
而在你的活动
,你可以做一个 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.
这篇关于如何调整动作条的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文