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

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

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

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

        Android:如何创建一个透明的以对话框为主题的活动

        时间:2023-08-31
      4. <tfoot id='qzE1Z'></tfoot>
        <i id='qzE1Z'><tr id='qzE1Z'><dt id='qzE1Z'><q id='qzE1Z'><span id='qzE1Z'><b id='qzE1Z'><form id='qzE1Z'><ins id='qzE1Z'></ins><ul id='qzE1Z'></ul><sub id='qzE1Z'></sub></form><legend id='qzE1Z'></legend><bdo id='qzE1Z'><pre id='qzE1Z'><center id='qzE1Z'></center></pre></bdo></b><th id='qzE1Z'></th></span></q></dt></tr></i><div id='qzE1Z'><tfoot id='qzE1Z'></tfoot><dl id='qzE1Z'><fieldset id='qzE1Z'></fieldset></dl></div>

          <tbody id='qzE1Z'></tbody>

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

                  <bdo id='qzE1Z'></bdo><ul id='qzE1Z'></ul>
                • <legend id='qzE1Z'><style id='qzE1Z'><dir id='qzE1Z'><q id='qzE1Z'></q></dir></style></legend>

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

                  问题描述

                  我最初的目标是模态对话框,但你知道,Android 不支持这种类型的对话框.或者,构建一个以对话为主题的活动可能会起作用.
                  这是代码,

                  My original goal here was a modal dialog, but you know, Android didn't support this type of dialog. Alternatively, building a dialog-themed activity would possibly work.
                  Here's code,

                  public class DialogActivity extends Activity {
                  
                  @Override
                  protected void onCreate(Bundle savedInstanceState) {
                  
                      setTheme(android.R.style.Theme_Dialog);
                  
                      super.onCreate(savedInstanceState);
                  
                      requestWindowFeature (Window.FEATURE_NO_TITLE);
                  
                      Button yesBtn = new Button(this);
                      yesBtn.setText("Yes");
                      yesBtn.setOnClickListener(new OnClickListener() {
                  
                          @Override
                          public void onClick(View v) {
                              // TODO Auto-generated method stub
                              DialogActivity.this.finish();
                  
                          }
                  
                      });
                  
                      this.setContentView(yesBtn);
                  }
                  

                  但是,背景总是黑色的,这真的很混乱.人们遇到了同样的问题,
                  http://code.google.com/p/android/issues/detail?id=4394
                  我只是想让它看起来更像用户的对话.那么,如何让这个 DialogActivity 透明且不覆盖底层屏幕呢?
                  谢谢.

                  However, the background was always black, that really confusing. People got same problem,
                  http://code.google.com/p/android/issues/detail?id=4394
                  I just wanna make it look more dialog-like for user. So, how to get this DialogActivity transparent and never cover underlying screen?
                  Thanks.

                  这就是我创建样式的方式

                  This was how I created the style

                  <style name="CustomDialogTheme" parent="android:Theme.Dialog">
                      <item name="android:windowBackground">@android:color/transparent</item>
                      <item name="android:windowNoTitle">true</item>
                      <item name="android:windowFullscreen">false</item>
                  </style>
                  

                  推荐答案

                  这样就可以创建一个透明的对话框了.

                  You can create a tranparent dialog by this.

                  public class DialogActivity extends Activity {
                      @Override
                      public void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
                          alertDialog.setTitle(" ");
                          alertDialog.setMessage("");
                          alertDialog.setIcon(R.drawable.icon);
                          alertDialog.setButton("Accept", new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int which) {                
                              }
                          });
                          alertDialog.setButton2("Deny", new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int which) {
                              }
                          });
                          alertDialog.show();
                      }
                  }
                  

                  在此之后,只需在 AndroidManifest.xml 中添加一行,您可以在其中定义清单中的活动.

                  After this just put a line in AndroidManifest.xml, where you define your activity in manifest.

                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  

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

                  上一篇:如何在对话框中使用数字选择器 下一篇:第二次在对话框中膨胀片段时出错

                  相关文章

                  最新文章

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

                    <bdo id='Tld2o'></bdo><ul id='Tld2o'></ul>
                  1. <legend id='Tld2o'><style id='Tld2o'><dir id='Tld2o'><q id='Tld2o'></q></dir></style></legend>

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

                  2. <tfoot id='Tld2o'></tfoot>