单击警告对话框按钮并在android中弹出对话框时,如何更改背景视图颜色。例如当对话框被填充时背景视图颜色变暗。
答案 0 :(得分:0)
在顶层添加XML,
图像查看首选,因为您可以给它任何你想要的颜色
<ImageView
android:id="@+id/iv_OverlayImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:visibility="gone"
android:clickable="true" />
最初将其可见性设置为GONE
点击后,当您的对话框打开时,将其设置为可见
overlayImage.setVisibility(View.VISIBLE);
将其设置为按下对话框中按下的任何按钮
overlayImage.setVisibility(View.GONE);
答案 1 :(得分:0)
您可以使用
v.setBackgroundColor(Color.WHITE);
或
v.setBackgroundColor(Color.parse("#ffffff"));
这会将背景颜色更改为white