使用样式文件,在values 目录下新建styles.xml文件,编写如下代码:
--></mce:style><style name="dialog" parent="@android:style/Theme.Dialog" mce_bogus="1"> <item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@android:color/black</item>
<item name="android:windowBackground">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
调用时,使用AlerDialog的接口类,Dialog 接口编写如下代码:
下面我们查看一下Dialog的源码文件,里面的构造函数为如下:
这里面我们可以看出,Android 使用了默认的构造函数为Dialog 设置样式,如果没有为其设置样式,即默认加载事先编写好的样式文件,Dialog 一共由多个9.png的图片构成,大部分都是带有边框的9.png图片,所以就是为什么我们上边的样式文件要将其背景去除掉。这个东西搞了我好久,希望对你有帮助。
转载:http://120.132.134.205/cmdn/supesite/?uid-49302-action-viewspace-itemid-813