【问题标题】:How to change the default background color of AlertDialog from translucent to transparentHow to change the default background color of AlertDialog from translucent to transparent
【发布时间】:2022-12-02 11:10:19
【问题描述】:

Want to do

I want to change the default background color of AlertDialog from translucent to transparent.

I don't want to change the color of white place.

What I tried

AddedstyletoAlertDialog.Builder. However, this code changed the background not only translucent but also white place.

styles.xml

<style name="TransparentDialogTheme" parent="@android:style/Theme.Light">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

MainActivity.cs

var layout = LayoutInflater.Inflate(Resource.Layout.dialog_eventLogOptionMenu, null);
var dlg = new AndroidX.AppCompat.App.AlertDialog.Builder(this, Resource.Style.TransparentDialogTheme).Create();

【问题讨论】:

    标签: c# android xamarin xamarin.android android-alertdialog


    【解决方案1】:

    You can try this to add this code &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt; to your style. It can remove the dark color in the alertdialog background.

    <style name="TransparentDialogTheme" parent="@android:style/Theme.Light">
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>
    

    【讨论】:

      猜你喜欢
      • 2022-12-26
      • 2022-12-28
      • 2022-12-27
      • 2022-12-27
      • 2022-12-27
      • 2022-12-02
      • 2022-12-27
      • 2022-12-02
      • 2022-11-20
      相关资源
      最近更新 更多