changing ActionBar's height in orientation mod

2019-02-20 01:08发布

问题:

I have been using actionbar(android native) for a few days(jellybean 4.2). I tried to change the actionbar's height by adding such line in style.xml:

100dip

it works fine in landscapemode, but do not work in orientation mode.

in orientation mode, its height was not changed.

回答1:

You just have to create dimensions for the height of the ActionBar in portrait and landscape mode:

values/dimens.xml:

<resources>
     <!-- dimension for the portrait ActionBar -->
     <dimen name="ab_height">100dp</dimen>
</resources>

values-land/dimens.xml:

<resources>
     <!-- dimension for the landscape ActionBar -->
     <dimen name="ab_height">120dp</dimen>
</resources>

Now you can use these dimensions like this:

<style [...]>
     <item name="android:actionBarSize">@dimen/ab_height</item>
</style>