我需要在我的 Android 应用程序中显示自定义对话框。标准AlertDialog
设计是不可接受的。 Android 文档说:
提示:如果您想要自定义对话框,您可以显示一个 Activity
作为对话框而不是使用对话框 API。只需创建一个
Activity 并将其主题设置为 Theme.Holo.Dialog
明显元素:
就是这样。该活动现在显示在对话框窗口中,而不是
全屏。
听起来很有希望。我做到了,但是透明度不起作用!背景始终是灰色的:
这是清单中的描述:
<activity
android:name=".MyDialogActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Dialog.NoActionBar" >
</activity>
这是我活动的根源:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#00000000"
android:layout_width="400dp"
android:layout_height="wrap_content" >
// Content ... //
</RelativeLayout>
我也尝试过android:background="@null"
- 效果是一样的。
如果我使用android:background="#ff0000"
然后它是红色的(应该是红色的)。但如何使其透明呢?
Update
我最终得到
<style name="MyThemeDialogCustom" parent="android:Theme.Holo.Dialog.NoActionBar" >
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
使主题像这样
<style name="ThemeDialogCustom">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
</style>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)