我创建了自己的自定义对话框,它工作正常,但我想将变暗的背景更改为自定义图案(例如图像文件或 xml 形状)。我怎样才能做到这一点?
请注意,我不想改变调光强度,但我只想用一种模式替换这种调光
我找到了解决这个问题的方法,我从 @vipul mittal 的回答中得出这个问题,
我应该将对话框主题设置如下:
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
对于这个主题,我的对话将是:
-
全屏因为
windowIsFloating
被设定为false
-
周围区域完全透明因为
windowBackground
被设定为@android:color/transparent
现在我应该用一个扮演周围区域角色的包装器来包装我的对话框 xml 布局内容,在本例中我选择了FrameLayout
为了这:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/dialog_back"> <!-- this is surrounding area drawable -->
<!-- dialog contents goes here -->
</FrameLayout>
Here is a screenshot of my final dialog:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)