2

I'm trying to change the height of my ActionBar, but it won't work. I have tried to set the height using the android:actionBarSize and android:height attributes. But nothing workds. Here is my theme.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyActionBarTheme"
        parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="actionBarStyle">@style/MyActionBar</item>
        <item name="android:itemBackground">@color/green_2x</item>
    </style>
    <style name="MyActionBar"
        parent="Widget.AppCompat.Light.ActionBar">
        <item name="android:background">@drawable/actionbar_background</item>
        <item name="background">@drawable/actionbar_background</item>
        <item name="android:height">10dp</item>
    </style>
</resources>

Any ideas to change the height of the ActionBar?

  • 1
    http://stackoverflow.com/questions/18670519/how-to-change-the-height-of-action-bar-in-android-4-2-2 An answer on this page suggests creating a themes.xml. The first linked question in the comments also suggests some attributes to use in your theme. See if that helps. – CubeJockey Apr 17 '15 at 18:02
  • i would suggest you to use Toolbar from support-v7.... you can do a lot of stuff easily with that – denvercoder9 Apr 17 '15 at 18:05
  • Thanks @Trobbins for the question link. With 40dp40dp it works :-) –  Apr 17 '15 at 18:07

2 Answers2

1

This might help you,

  <style name="ActionBarStyle" parent="Widget.AppCompat.Light.ActionBar">
    <item name="android:background">@drawable/actionbar_background</item>
    <item name="background">@drawable/actionbar_background</item>
    <item name="android:height">10dp</item>
    <item name="height">10dp</item>
  </style>
dhun
  • 643
  • 7
  • 13
1
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>
<style name="Base.Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light">
<style name="Base.Theme.AppCompat.Light" parent="Base.V7.Theme.AppCompat.Light">
<style name="Base.V7.Theme.AppCompat.Light" parent="Platform.AppCompat.Light">

And the Base.V7.Theme.AppCompat.Light contains

<item name="actionBarSize">@dimen/abc_action_bar_default_height_material</item>

So, you need to change only actionBarSize in your main theme.

smb
  • 834
  • 1
  • 8
  • 17