• <bdo id='AIjVw'></bdo><ul id='AIjVw'></ul>

      <legend id='AIjVw'><style id='AIjVw'><dir id='AIjVw'><q id='AIjVw'></q></dir></style></legend>

      <small id='AIjVw'></small><noframes id='AIjVw'>

    1. <i id='AIjVw'><tr id='AIjVw'><dt id='AIjVw'><q id='AIjVw'><span id='AIjVw'><b id='AIjVw'><form id='AIjVw'><ins id='AIjVw'></ins><ul id='AIjVw'></ul><sub id='AIjVw'></sub></form><legend id='AIjVw'></legend><bdo id='AIjVw'><pre id='AIjVw'><center id='AIjVw'></center></pre></bdo></b><th id='AIjVw'></th></span></q></dt></tr></i><div id='AIjVw'><tfoot id='AIjVw'></tfoot><dl id='AIjVw'><fieldset id='AIjVw'></fieldset></dl></div>

        <tfoot id='AIjVw'></tfoot>
      1. 如何更改默认的黑色暗淡背景“颜色"?(不是

        时间:2023-08-31
          <tbody id='zaiaU'></tbody>
        1. <small id='zaiaU'></small><noframes id='zaiaU'>

              <i id='zaiaU'><tr id='zaiaU'><dt id='zaiaU'><q id='zaiaU'><span id='zaiaU'><b id='zaiaU'><form id='zaiaU'><ins id='zaiaU'></ins><ul id='zaiaU'></ul><sub id='zaiaU'></sub></form><legend id='zaiaU'></legend><bdo id='zaiaU'><pre id='zaiaU'><center id='zaiaU'></center></pre></bdo></b><th id='zaiaU'></th></span></q></dt></tr></i><div id='zaiaU'><tfoot id='zaiaU'></tfoot><dl id='zaiaU'><fieldset id='zaiaU'></fieldset></dl></div>

              <tfoot id='zaiaU'></tfoot>
                <legend id='zaiaU'><style id='zaiaU'><dir id='zaiaU'><q id='zaiaU'></q></dir></style></legend>
                  <bdo id='zaiaU'></bdo><ul id='zaiaU'></ul>
                  本文介绍了如何更改默认的黑色暗淡背景“颜色"?(不是dim的量)Dialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  (这是一张随机图片,显示了在 Internet 上找到的 Dialog.)

                  (This is a random image of showing a Dialog found on the Internet.)

                  我一直在实现一个自定义 Dialog.我可以处理对话框上的几乎所有内容,除了对话框本身下的默认黑色暗背景,但在它后面的整个屏幕上.基本上我想改变它的 color 和 alpha 值.

                  I've been implementing a custom Dialog. I could handle almost everything on the dialog except for that default black dim background under the dialog itself, but over the entire screen behind it. Basically I want to change its color and alpha value.

                  我一直在 StackOverflow 中徘徊,但我找到的唯一答案是关于更改 Dialog 本身的背景.无论如何,如果您需要它,这是我的简单代码.

                  I've been wandering through StackOverflow but only answers I found were about changing background of Dialog itself. In any case if you need it, here's my simple codes.

                  public class HTDialog extends Dialog{
                  
                      public HTDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
                          super(context, cancelable, cancelListener);
                          requestWindowFeature(Window.FEATURE_NO_TITLE);
                          setCanceledOnTouchOutside(true);
                          setContentView(R.layout.custom_dialog);
                      }
                  }
                  

                  custom_dialog.xml

                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/dialog_root"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:minWidth="280dp"
                      android:background="@drawable/bg_popup"
                      android:paddingTop="20dp">
                  
                      <ImageView
                          android:id="@+id/dialog_image"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_centerHorizontal="true"
                          android:src="@drawable/icon" />
                  
                  </RelativeLayout>
                  

                  推荐答案

                  这是一种变通方法,但它并不是真正的纯粹解决方案,因为背景触摸已禁用,应手动配置.

                  This is a workaround but it's not really a pure solution because background touch is disabled and should be configured manually.

                  首先,像这样设置自定义对话框主题.

                  First, set custom dialog theme like this.

                  <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>
                  

                  windowIsFloating 设置为 false 会强制 Dialog 视图扩展到全屏.将 windowBackground 设置为 transparent 会移除 Dialog 下的默认黑色暗淡背景.windowNoTitle 选项去掉上方的标题栏.

                  Setting windowIsFloating to false forces Dialog view to be expanded to full screen. Setting windowBackground to transparent removes default black dim background under Dialog. windowNoTitle option gets rid of the upper title bar.

                  应用主题并构建您的 custom_dialog 视图,如下所示.

                  Apply the theme and construct your custom_dialog view as follows.

                  public HTCustomDialog(Context context) {
                      super(context, R.style.CustomDialogTheme);
                      setContentView(R.layout.custom_dialog);
                  }
                  

                  custom_dialog.xml

                  <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 视图是全屏视图,请将根布局的 background 设置为您喜欢的任何颜色.

                  Now that CustomDialog view is a full-screen view, set background of your root layout to whatever color you'd like.

                  我将结果镶嵌了一点.

                  这篇关于如何更改默认的黑色暗淡背景“颜色"?(不是dim的量)Dialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:定时无模式对话 下一篇:Android从一个对话框显示另一个对话框

                  相关文章

                  最新文章

                • <small id='DLByI'></small><noframes id='DLByI'>

                  <legend id='DLByI'><style id='DLByI'><dir id='DLByI'><q id='DLByI'></q></dir></style></legend>

                    <i id='DLByI'><tr id='DLByI'><dt id='DLByI'><q id='DLByI'><span id='DLByI'><b id='DLByI'><form id='DLByI'><ins id='DLByI'></ins><ul id='DLByI'></ul><sub id='DLByI'></sub></form><legend id='DLByI'></legend><bdo id='DLByI'><pre id='DLByI'><center id='DLByI'></center></pre></bdo></b><th id='DLByI'></th></span></q></dt></tr></i><div id='DLByI'><tfoot id='DLByI'></tfoot><dl id='DLByI'><fieldset id='DLByI'></fieldset></dl></div>
                    <tfoot id='DLByI'></tfoot>

                      • <bdo id='DLByI'></bdo><ul id='DLByI'></ul>