Android 改变支撑作用杆的高度

Android 改变支撑作用杆的高度,android,android-actionbar,android-appcompat,Android,Android Actionbar,Android Appcompat,我正在使用V7支持库,我只想在某些活动中更改操作栏的高度 这是my styles.xml: 但是看起来,Home的actionbar并没有改变 如何使用AppCompat编辑操作栏高度?如有任何帮助,将不胜感激: 谢谢。在your styles.xml中 <!-- Define a base Theme that inherits from the one you want (dark, light, light with Dark action bar... --> <sty

我正在使用V7支持库,我只想在某些活动中更改操作栏的高度

这是my styles.xml:

但是看起来,Home的actionbar并没有改变

如何使用AppCompat编辑操作栏高度?如有任何帮助,将不胜感激:

谢谢。

在your styles.xml中

<!-- Define a base Theme that inherits from the one you want (dark, light, light with Dark action bar... -->
<style name="AppBaseTheme" parent="Theme.Base.AppCompat">
</style>
<!-- Create sub themes necessaries and edit the actionBar style for them -->
<style name="AppTheme1" parent="AppBaseTheme"> 
  <item name="actionBarStyle">@style/ActionBarStyleBig</item>
</style>

<style name="AppTheme2" parent="AppBaseTheme">
  <item name="actionBarStyle">@style/ActionBarStyleSmall</item>
</style>
<!-- Edit on any of them the height for actionBar -->
<style name="ActionBarStyleBig" parent="@style/Widget.AppCompat.ActionBar.Solid">
  <item name="height">@dimen/bigActionBAr</item>
</style>

<style name="ActionBarStyleSmall" parent="@style/Widget.AppCompat.ActionBar.Solid">
  <item name="height">@dimen/smallActionBar</item>
</style>
请注意,在Api<11中,高度指定为name=height,但在Api>10中,需要使用name=android:height才能正常工作。这意味着您还需要在位于文件夹values-v11和values-v14的styles.xml以及您可能拥有的任何其他styles.xml中创建这些主题

在清单中,只需使用您需要的主题:

<activity
  android:name="com.example.myfirstapp.MainActivity"
  android:label="@string/app_name"
  android:theme="@style/AppTheme1" >
</activity>
<activity
  android:name="com.example.myfirstapp.SecondActivity"
  android:label="@string/title_activity_second"
  android:theme="@style/AppTheme2>
请记住并重新检查,您没有在任何其他styles.xml中覆盖此设置

<!-- Define a base Theme that inherits from the one you want (dark, light, light with Dark action bar... -->
<style name="AppBaseTheme" parent="Theme.Base.AppCompat">
</style>
<!-- Create sub themes necessaries and edit the actionBar style for them -->
<style name="AppTheme1" parent="AppBaseTheme"> 
  <item name="actionBarStyle">@style/ActionBarStyleBig</item>
</style>

<style name="AppTheme2" parent="AppBaseTheme">
  <item name="actionBarStyle">@style/ActionBarStyleSmall</item>
</style>
<!-- Edit on any of them the height for actionBar -->
<style name="ActionBarStyleBig" parent="@style/Widget.AppCompat.ActionBar.Solid">
  <item name="height">@dimen/bigActionBAr</item>
</style>

<style name="ActionBarStyleSmall" parent="@style/Widget.AppCompat.ActionBar.Solid">
  <item name="height">@dimen/smallActionBar</item>
</style>
希望能有帮助。我试过并成功了。

你应该使用actionBarSize


你不应该那样做。很难做到这一点是有原因的,它应该保持系统标准高度,以便与平台保持连续性。@Booger谢谢。所以它可以在不重新设计所有内容的情况下进行更新?
<activity
  android:name="com.example.myfirstapp.MainActivity"
  android:label="@string/app_name"
  android:theme="@style/AppTheme1" >
</activity>
<activity
  android:name="com.example.myfirstapp.SecondActivity"
  android:label="@string/title_activity_second"
  android:theme="@style/AppTheme2>
<style name="AppTheme1" parent="AppBaseTheme"> 
  <item name="actionBarSize">@dimen/actionbar_height</item>
</style>