changing ActionBar's height in orientation mod

2019-02-20 00:35发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-02-20 01:20

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> 
查看更多
登录 后发表回答