问题
I've created a new style to set the background as transparent, but for some reason ever since the app doesn't change layout to landscape when device is rotated. Should I specify something in the new style ?
Here is it's code :
< style name="Transparent" parent="android:@Theme.Translucent">
< item name="android:windowBackground">@color/background</item>
</style>
回答1:
While you are not specify android:screenOrientation for activty, android uses
"unspecified"
default value, which means that the system chooses the orientation.
In a case you are using style with <item name="android:windowIsTranslucent">true</item>
, system selects an orientation based on the orientation of underlying activity in stack. So it's hard to get your application in landscape mode, because most of launchers fixed to portrait.
Just set android:screenOrientation="sensor"
for all Translucent activities to force it choose orientation independently:
<activity
android:name=".SomeActivity"
android:screenOrientation="sensor"
...>
...
</activity>
回答2:
I actually kinda solved it apparently the orientation is according to the background app in case of transparent background, since i kept testing when the Launcher in the back, i always got portrait only.
回答3:
just right in manifest
<activity
android:name=".Ippin_NewActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name" >
</activity>
来源:https://stackoverflow.com/questions/13101459/androidtheme-translucent-locks-orientation-to-portrait