no orientation notification when translucent set

可紊 提交于 2019-12-06 13:47:44

I had a same problem. Just add android:screenOrientation="sensor" in the manifest file after you specify theme:

    <activity
        android:name=".SplashActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:screenOrientation="sensor">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

So far I tested it on android 2.2 and 4.1 - works as expected.

I have a same problem... but in my case I used Translucent because I solve redrawn warning (this warning appear when set color on android:background)

I solved the warning creating a Theme with parent Theme.Lignt and rewrite two attributes

Something like this

<style name="MyTheme" parent="android:Theme.Light">
    <item name="android:windowBackground">@color/my_background</item>
    <item name="android:colorBackground">@color/my_background</item>        
</style>

If you need use Translucent in ApiDemos has a sample when an activity have a translucent theme and orientation service works well

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