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

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

        <tfoot id='xag9C'></tfoot>
      1. <legend id='xag9C'><style id='xag9C'><dir id='xag9C'><q id='xag9C'></q></dir></style></legend>

        在活动之上创建一个透明对话框

        时间:2023-08-28
      2. <tfoot id='XMs1q'></tfoot>
          <bdo id='XMs1q'></bdo><ul id='XMs1q'></ul>

              <tbody id='XMs1q'></tbody>

                <i id='XMs1q'><tr id='XMs1q'><dt id='XMs1q'><q id='XMs1q'><span id='XMs1q'><b id='XMs1q'><form id='XMs1q'><ins id='XMs1q'></ins><ul id='XMs1q'></ul><sub id='XMs1q'></sub></form><legend id='XMs1q'></legend><bdo id='XMs1q'><pre id='XMs1q'><center id='XMs1q'></center></pre></bdo></b><th id='XMs1q'></th></span></q></dt></tr></i><div id='XMs1q'><tfoot id='XMs1q'></tfoot><dl id='XMs1q'><fieldset id='XMs1q'></fieldset></dl></div>
              • <legend id='XMs1q'><style id='XMs1q'><dir id='XMs1q'><q id='XMs1q'></q></dir></style></legend>
              • <small id='XMs1q'></small><noframes id='XMs1q'>

                  本文介绍了在活动之上创建一个透明对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在当前活动的顶部放置一个图层,该图层可以解释当前屏幕上发生的情况,类似于 contact+ 应用程序 .

                  I'm trying to put a layer on top of the current activity which would have explanation of what is going on on the current screen, similar to what occurs on contact+ app .

                  我知道有一些解决方案(例如 showCase 库 和 superToolTips 库),我也知道我可以创建一个视图并通过将其添加到活动的窗口将其设置在顶部,但我需要将整个对话框层放在顶部.

                  I know there are some solutions for this (like the showCase library and the superToolTips library ) , and I also know that I can create a view and set it on top by adding it to the window of the activity , but I need put a whole dialog layer on top.

                  无论我尝试什么,每个解决方案都无法按照我需要的方式工作.

                  No matter what I try, each solution doesn't work the way I need it to work.

                  简而言之,我需要的是:

                  in short , what I need is:

                  • 全屏对话框.

                  • full screen dialog.

                  操作栏、通知栏和后面活动的内容没有变化(不是视觉上的,也不是逻辑上的),这意味着对话框后面的所有内容都与显示对话框之前显示的内容保持一致.

                  no change (not visual and not logical) to the action bar, notification bar, and content of the activity behind, meaning that everything behind the dialog stays the same it was shown a moment before the dialog was shown.

                  除了我用于对话框的视图外,应该是透明的,应该正常显示.

                  be transparent except for the views I use for the dialog, which should be shown normally.

                  可悲的是,我总是只得到我需要的一部分.

                  Sadly, I've always got only a part of the things I needed.

                  这是我的代码:

                  styles.xml:

                  styles.xml:

                  <style name="full_screen_dialog">
                          <item name="android:windowFrame">@null</item>
                          <item name="android:windowIsFloating">true</item>
                          <item name="android:windowContentOverlay">@null</item>
                          <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
                          <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
                      </style>
                  

                  MainActivity.java:

                  MainActivity.java:

                  ...
                  final Dialog dialog = new Dialog(this, R.style.full_screen_dialog);
                  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                  dialog.setContentView(R.layout.floating_tutorial);
                  dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
                  dialog.getWindow().setFormat(PixelFormat.TRANSLUCENT);
                  dialog.show();
                  

                  这段代码会将布局放在活动的顶部,但遗憾的是它没有任何透明度,即使我已经设置了它.我使用的布局非常简单,所以我不发布它.

                  This code will put the layout on top of the activity, but sadly it doesn't have any transparency , even though I've set it . The layout I've used is very simple which is why I don't post it.

                  我错过了什么?应该怎么做才能修复代码?

                  what am I missing ? what should be done to fix the code?

                  如何使对话框既透明、全屏又不会更改操作栏和通知栏.

                  how can I make the dialog both transparent, full screen AND that it won't change the action bar and notifications bar.

                  找到一个好的解决方案后,这里是工作代码:

                  after finding a good solution, here's the working code:

                  @Override
                  protected void onCreate(final Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.activity_main);
                      final Dialog dialog = new Dialog(this);
                      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                      dialog.setContentView(R.layout.floating_tutorial);
                      final Window window = dialog.getWindow();
                      window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
                      window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                      window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                      dialog.show();
                  }
                  

                  推荐答案

                  只需更改 Dialog 的背景颜色即可:

                  Just change the background color of your Dialog:

                  dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                  

                  这可以防止暗淡效果:

                  dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                  

                  这篇关于在活动之上创建一个透明对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:哪里可以找到关于 swift alert (UIAlertController) 的清 下一篇:方向更改时的 DialogFragment 回调

                  相关文章

                  最新文章

                  <tfoot id='aPBZI'></tfoot>
                    <bdo id='aPBZI'></bdo><ul id='aPBZI'></ul>

                  1. <small id='aPBZI'></small><noframes id='aPBZI'>

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