如何设置动作条的标签为Android的高度如何设置、高度、动作、标签

2023-09-05 02:47:07 作者:再爱也不易

基本上,我想改变为其他动作选项卡的高度。这个问题已经被问了几次的计算器,例如:

Basically, I want to change the height of the tabs in actionbars. This questions has been asked several times on stackoverflow, for example:

动作条的标签高度

我已经试过大部分的解决方案,但没有工作,这是我的code。

I have tried most of the solutions but nothing work, here is my code.

    <style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
    <item name="android:scrollHorizontally">false</item>
    <item name="android:paddingLeft">0dp</item>
    <item name="android:paddingRight">0dp</item>
    <item name="android:actionBarSize">80dp</item>
    <item name="actionBarSize">80dp</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
</style>

<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:height">80dp</item>
</style>

显然,code只改变动作条的高度,而不是我想要的标签栏的高度。下面是图片,以供参考:

Apparently, the code only change the actionbar height, not the tab bar height as I want. Here is the picture for reference:

正如你所看到的,在底部的动作条越高。但在动作条模式中,翼片高度保持相同。

As you can see, the actionbar on the bottom is higher. But in actionbar mode, the tabs height remain the same.

这是怎么回事?我错过了什么??? 预先感谢您:)

Why is this happening? Did i miss something??? Thank you in advance :).

解决,如提及:

ActionBar与导航标签高度的变化与屏幕方向

https://$c$c.google.com/p/android/issues/detail?id=41792

显然,这是Android SDK中的一个错误......从未想过我会遇到一个错误这样的:(。希望这会帮助其他人。

Apparently this is a bug from android sdk ... Never though I would encounter a bug like this :(. Hope this help other people.

推荐答案

通过设置两个应用主题属性机器人:actionBarSize和ActionBar.TabView样式属性安卓了minHeight(或高)80 DP。 一个基本的例子:

By setting both the Application theme attribute android:actionBarSize and the ActionBar.TabView style attribute android:minHeight (or height) to 80 dp. A basic example:

<style name="ThemeHoloWithActionBar" parent="android:Theme.Holo.Light">
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
    <item name="android:actionBarSize">80dp</item>
</style>

<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:minHeight">80dp</item>
</style>

在清单设置主题:

   <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/ThemeHoloWithActionBar" >

活动

        ActionBar actionbar = getActionBar();
        actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionbar.setDisplayShowTitleEnabled(false);
        actionbar.setDisplayShowHomeEnabled(false);
        ActionBar.Tab tabA = actionbar.newTab().setText("Tab A");
        ActionBar.Tab tabB = actionbar.newTab().setText("Tab B");
        ActionBar.Tab tabC = actionbar.newTab().setText("Tab C");
        tabA.setTabListener(new MyTabsListener());
        tabB.setTabListener(new MyTabsListener());
        tabC.setTabListener(new MyTabsListener());
        actionbar.addTab(tabA);
        actionbar.addTab(tabB);
        actionbar.addTab(tabC);
 
精彩推荐
图片推荐