Android 有没有办法删除AlertDialog的背景?
我正在尝试更改Android AlertDialog的背景色 我看到的每一篇文章都是关于改变AlertDialog的颜色,而不是背后的背景 任何帮助都将不胜感激Android 有没有办法删除AlertDialog的背景?,android,colors,background,android-alertdialog,Android,Colors,Background,Android Alertdialog,我正在尝试更改Android AlertDialog的背景色 我看到的每一篇文章都是关于改变AlertDialog的颜色,而不是背后的背景 任何帮助都将不胜感激 您可以减少变暗量 dialog.getWindow().setDimAmount(0.5f); 要获得背景色,您需要创建一个自定义警报对话框。您可以减少暗量 dialog.getWindow().setDimAmount(0.5f); <style name="MyDialogTheme" parent="Theme.AppC
您可以减少变暗量
dialog.getWindow().setDimAmount(0.5f);
要获得背景色,您需要创建一个自定义警报对话框。您可以减少暗量
dialog.getWindow().setDimAmount(0.5f);
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@color/myColor</item>
要获得背景色,您需要创建一个自定义警报对话框
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@color/myColor</item>
有关更多信息,请参阅
有关更多信息,请参见有一种方法可以满足您的要求,但这不是一个很好的解决方案 首先,像这样设置自定义对话框主题 styles.xml
<style name="CustomDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_solid_80">
<RelativeLayout
android:id="@+id/dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/bg_popup"
android:padding="16dp">
</RelativeLayout>
自定义对话框.xml
<style name="CustomDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_solid_80">
<RelativeLayout
android:id="@+id/dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/bg_popup"
android:padding="16dp">
</RelativeLayout>
现在CustomDialog视图是一个全屏视图,将根布局的背景设置为您想要的任何颜色
我从“看一看”中得到了这个答案。有一种方法可以满足您的要求,但这不是一个很好的解决方案 首先,像这样设置自定义对话框主题 styles.xml
<style name="CustomDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_solid_80">
<RelativeLayout
android:id="@+id/dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/bg_popup"
android:padding="16dp">
</RelativeLayout>
自定义对话框.xml
<style name="CustomDialogTheme" parent="android:Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_solid_80">
<RelativeLayout
android:id="@+id/dialog_root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:background="@drawable/bg_popup"
android:padding="16dp">
</RelativeLayout>
现在CustomDialog视图是一个全屏视图,将根布局的背景设置为您想要的任何颜色
我从“看一看”中得到了这个答案