开发者

no orientation notification when translucent set

Using phones that have android 2.1 & 2.2 installed, using the simplest case of a hello world app and add android:the开发者_高级运维me="@android:style/Theme.Translucent" to the activity in the android manifest to have the app be transparent, the app sticks as portrait only and won't rotate to landscape when the phone is rotated.

Take the line out and the app rotates ok. This is verified by adding the override of onConfigurationChanged and putting a breakpoint in that routine. Brk hits when translucent isn't applied, doesn't when you add translucency.

However, using a samsung galaxy tab using andr 2.2, rotation works ok even with translucent applied. Anyone have any ideas on this?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜