Android 为xml上显示为对话框的活动设置透明背景不适用于所有设备
我对显示为对话框的活动有一个自定义视图。 我将自定义主题应用于我的活动,使其父级为:“@android:style/theme.Dialog”,并将窗口背景更改为透明 My Manifest.xml:Android 为xml上显示为对话框的活动设置透明背景不适用于所有设备,android,android-styles,android-background,Android,Android Styles,Android Background,我对显示为对话框的活动有一个自定义视图。 我将自定义主题应用于我的活动,使其父级为:“@android:style/theme.Dialog”,并将窗口背景更改为透明 My Manifest.xml: <activity android:name="com.rev.revcorder.ui.UserAuthenticationDialogActivity" android:screenOrientation="portrait" android:theme="@st
<activity android:name="com.rev.revcorder.ui.UserAuthenticationDialogActivity" android:screenOrientation="portrait"
android:theme="@style/userAuthenticationDialog">
</activity>
我的问题是,在我的xml样式上设置窗口背景和在语法上设置有什么区别?
还有,为什么它在我的设备上工作,而不是在另一个相同的设备上
感谢您的帮助您可以为所有设备制作一个
自定义主题
例如,这里是一个自定义主题的声明,它只是标准平台的默认灯光主题。它将放在res/values
下的XML文件中(通常是res/values/styles.XML
):
现在像使用其他主题一样使用此主题,如果在Android 3.0或更高版本上运行,您的应用程序将自动切换到全息主题
有关根据平台版本或其他设备配置提供替代资源(如主题和布局)的更多信息,请参阅文档
下图显示了u如何构造资源
更新:
还可以尝试将下面的主题设置为manifest.xml
android:theme="@android:style/Theme.Translucent.NoTitleBar"
向样式中再添加2个属性,如以下代码所示:
<style name="userAuthenticationDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>
@android:彩色/透明
真的
真的
问题不在于API级别。两台设备都运行Android 4.4。我需要活动视图透明并显示为对话框,这就是我使用“@Android:style/Theme.dialog”的原因
<style name="LightThemeSelector" parent="android:Theme.Light">
...
</style>
<style name="LightThemeSelector" parent="android:Theme.Holo.Light">
...
android:theme="@android:style/Theme.Translucent.NoTitleBar"
<style name="userAuthenticationDialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>