android:@Theme.Translucent Locks orientation to Portrait?

烈酒焚心 提交于 2020-01-02 07:39:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!