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

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

    3. <legend id='h8FDk'><style id='h8FDk'><dir id='h8FDk'><q id='h8FDk'></q></dir></style></legend>

      <tfoot id='h8FDk'></tfoot>

        Android:对话框在 droid 3 上有额外的、丑陋的空间

        时间:2023-08-30

          • <bdo id='4Db9q'></bdo><ul id='4Db9q'></ul>

              <tbody id='4Db9q'></tbody>
            <tfoot id='4Db9q'></tfoot>
            • <legend id='4Db9q'><style id='4Db9q'><dir id='4Db9q'><q id='4Db9q'></q></dir></style></legend>

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

              <small id='4Db9q'></small><noframes id='4Db9q'>

                1. 本文介绍了Android:对话框在 droid 3 上有额外的、丑陋的空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  第一张图片来自 Galaxy Note,第二张来自 Droid 3.它们都由以下代码生成.

                  The first image is from a Galaxy Note, the second is from a Droid 3. Both of them produced from the below code.

                  Droid 3 上的对话框有大量额外的、难看的空间.这个空间在更复杂的对话框上更加丑陋.有什么办法可以预防吗?

                  The dialog on the Droid 3 has a significant amount of extra, ugly space. This space is even uglier on more complex dialogs. Is there any way to prevent it?

                  public void onCreate(Bundle bundle)
                      {
                          super.onCreate(bundle);
                  
                          TextView tv = new TextView(this);
                          tv.setText("Hello!");
                  
                          Dialog dialog = new Dialog(this);
                          dialog.setContentView(tv);
                          dialog.setTitle("Hi!");
                  
                          dialog.show();
                      }
                  

                  推荐答案

                  这些 Droid UI 定制让我抓狂!

                  These Droid UI customizations drive me crazy!

                  如果您想控制您的对话框以使它们在设备之间保持一致,您可以使用提供样式参数的构造函数将它们简化为基础.以下示例给出了一个如下所示的对话框:

                  If you'd like to control your dialogs to make them consistent across devices, you can strip them down to the basics with a constructor that supplies a style parameter. The following example gives a dialog that looks like this:

                  首先,像这样实例化您的对话框(或者更好的是,创建一个扩展 Dialog 的自定义类,以便您可以重用它):

                  First, instantiate your dialog like this (or better yet, create a custom class that extends Dialog so you can reuse it):

                  Dialog dialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
                  dialog.setContentView(R.layout.custom_dialog_layout);
                  

                  然后,提供一个 custom_dialog_layout.xml(可能看起来像这样):

                  Then, supply a custom_dialog_layout.xml (could look something like this):

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/layout_root"
                      style="@style/VerticalLinearLayout"
                      android:background="@android:color/transparent"
                      android:gravity="center_vertical|center_horizontal" >
                  
                      <LinearLayout
                          android:id="@+id/dialog_layout"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_margin="10dp"
                          android:background="@drawable/dialog_background"
                          android:orientation="vertical" >
                  
                          <TextView
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:padding="5dp"
                              android:textColor="@android:color/white"
                              android:text="Hi!" />
                  
                          <TextView
                              android:layout_width="fill_parent"
                              android:layout_height="wrap_content"
                              android:padding="5dp"
                              android:textColor="@android:color/white"
                              android:text="Hello!" />
                  
                      </LinearLayout>
                  </LinearLayout>
                  

                  dialog_background.xml 看起来像这样:

                  where dialog_background.xml looks something like this:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <shape xmlns:android="http://schemas.android.com/apk/res/android" >
                  
                      <corners android:radius="10dp" />
                  
                      <stroke
                          android:width="1dp"
                          android:color="@android:color/black" />
                  
                      <gradient
                          android:angle="0"
                          android:startColor="@android:color/white"
                          android:endColor="@android:color/white" />
                  
                  </shape>
                  

                  如果你真的想变得花哨,你可以尝试使用类似这样的答案在代码中对 dialog_layout 应用阴影:https://stackoverflow.com/a/372​​3654/475217

                  And if you really want to get fancy, you could try applying a drop shadow to the dialog_layout in code using something like this SO answer: https://stackoverflow.com/a/3723654/475217

                  这篇关于Android:对话框在 droid 3 上有额外的、丑陋的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android - java.lang.IllegalArgumentException 在 2.1 和低 a 下一篇:使用 onDismiss() 从 DialogFragment 获取信息

                  相关文章

                  最新文章

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

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

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