AlertDialog自定义背景

AlertDialog customize background

我的样式有问题。我想准备 AlertDialog 完全用黄色没有阴影。下面是代码:

 AlertDialog.Builder alert = new AlertDialog.Builder(About.this, R.style.Mystyle);

 <style name="AppTheme" parent="Theme.AppCompat">
 <item name="android:dialogTheme">@style/Mystyle.Dialog</item>
 <style name="Mystyle.Dialog" parent="Theme.AppCompat.Light.Dialog">

        <item name="colorAccent">@color/color_accent</item>

        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowCloseOnTouchOutside">false</item>

有什么帮助吗?实际上消息是白色的。

如果您使用 AlertDialog 并应用自定义样式,尽管您已将 android:windowBackground 设置为透明,它仍然会显示黑色阴影。

因此您需要使用 Dialog 并将自定义样式应用于它,这将解决您的问题。