使用安装了android 2.1 & 2.2
的手机,使用最简单的hello world应用程序并将 android:theme =“@ android:style / Theme.Translucent”添加到活动中Android应用程序清单使应用程序透明,应用程序仅作为肖像,并且在手机旋转时不会旋转到横向。
取出线,应用程序旋转正常。通过添加override of onConfigurationChanged
并在该例程中添加断点来验证这一点。 Brk在未应用半透明时命中,在添加半透明时不会命中。
但是,使用andr 2.2 的三星galaxy标签,即使应用了半透明,旋转也能正常工作。有人对此有任何想法吗?
答案 0 :(得分:5)
我遇到了同样的问题。在指定theme:
后,只需在清单文件中添加android:screenOrientation =“sensor” <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>
到目前为止,我在Android 2.2和4.1上测试过它 - 按预期工作。
答案 1 :(得分:1)
我有同样的问题...但在我的情况下,我使用了半透明,因为我解决了重绘警告(当在android:background上设置颜色时出现此警告)
我解决了使用父Theme.Lignt创建主题的警告,并重写了两个属性
像这样的东西
<style name="MyTheme" parent="android:Theme.Light">
<item name="android:windowBackground">@color/my_background</item>
<item name="android:colorBackground">@color/my_background</item>
</style>
如果你需要使用Translucent in ApiDemos有一个样本,当一个活动有一个半透明的主题和定向服务运作良好