Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android custom theme: different theme for landscape and portrait mode

I apply a custom theme to my activity with: <activity android:theme="@style/MyTheme">, in which I define the size of the ActionBarSherlock I use in this activity. Something like that:

<style name="MyTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarSize">45dp</item>                             
    <item name="android:actionBarSize">45dp</item>     
</style>

While this size is good for portrait mode, I find it too big in landscape mode. How can I apply a different theme in landscape mode or how could I just change the action bar size when the user uses the application in landscape orientation? Any suggestions? Thank you.

like image 465
Fred Avatar asked Apr 16 '12 11:04

Fred


People also ask

How do I manage portrait and landscape on Android?

Rotate your phone to change the screen orientation (if Auto Rotate is enabled). If Auto Rotate is enabled, your phone's screen will automatically flip to portrait mode when you are holding it upright. When you are holding it horizontally, it will automatically switch to Landscape mode.


1 Answers

create two different styles.xml. Put one into res/values-port and the other into res/values-land

like image 128
Renard Avatar answered Nov 15 '22 19:11

Renard