【问题标题】:How to set actionbar height using appcompat library?如何使用 appcompat 库设置操作栏高度?
【发布时间】:2014-12-07 18:18:46
【问题描述】:

如何更改操作栏的高度?我不知道为什么这不起作用。这就是我所做的:

res/values/styles.xml

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">

        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->

        <item name="actionBarStyle">@style/ActionBarStyle</item>
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

我已经创建了另一个styles.xml文件,这样我就可以使用android的命名空间了。

res/values-v11/styles.xml

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>

还有actionbar的样式文件:

res/values/my_custom_style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">
        <item name="android:height">80dp</item>
        <item name="height">80dp</item>
    </style>
</resources>

清单文件:

<application
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme" >
<activity
            android:name=".MainActivity"
            android:screenOrientation="portrait" />
</application>

这不起作用,高度没有改变。我已经在 Android 4.4.2 上测试过。

【问题讨论】:

    标签: android xml android-actionbar-compat


    【解决方案1】:

    res/values-v11/styles.xml 上也设置actionBarStyle。这是兼容性支持所必需的

    res/values-v11/styles.xml

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/ActionBarStyle</item>
        <item name="android:actionBarStyle">@style/ActionBarStyle</item>
    </style>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多