安卓中-修改操作栏尺寸

修改操作栏尺寸:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/CustomActionBar</item>
</style>
<style name="CustomActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <!--  <item name="android:background">@drawable/action_bar_style</item> -->
    <item name="android:actionBarSize">15dp</item>
    <item name="android:background">@drawable/header_bar</item>
</style>

但是尺寸没发现变化。使用的是api11

您需要使用 getActionBar().setCustomView() 方法来设置操作栏的自定义视图,然后在自定义视图中使用您的自定义尺寸。如果您想要直接更改操作栏的尺寸,则可以尝试使用 getActionBar().setHeight() 方法,但是这个方法已在APIlevel 18中废弃。


另外,需要注意的是,从APIlevel 21开始,您可以使用 android:height 属性来控制操作栏的尺寸。


此外,请确保您的自定义主题已正确应用于您的应用,并且您正在使用正确的主题引用。