【问题标题】:AlertDialog broken layout on some devices某些设备上的 AlertDialog 布局损坏
【发布时间】:2015-05-14 08:58:31
【问题描述】:

我在使用以下方法创建 AlertDialog 时遇到问题:

AlertDialog.Builder alertDialog = new AlertDialog.Builder(this)
    .setTitle(R.string.deletion_title)
    .setMessage(R.string.options_deleteExternalConfirm)
    .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Utils.deleteExternalDir();
                dialog.cancel();
            }
        })
    .setNegativeButton(R.string.no, null);
alertDialog.show();

虽然对话框在大多数设备上看起来不错,但在其他设备(即 Galaxy S4 - GT-I9505 和 Android 5.0.1)上存在布局问题,请参见附图:。 这是什么原因,我该如何解决?

(除了在Build.PRODUCT.equals("GT-I9505") 时向自定义对话框添加填充,因为那里可能有手机有相同的问题但我不知道)

【问题讨论】:

  • 我觉得手机有问题,你可以重启手机试试还是换个同类型的手机?
  • 重启并没有改变任何东西。组织另一个相同类型的设备是个好主意
  • 是的....检查并告诉我它是否正常工作...如果我会遇到此类问题,我可以跟进。
  • 我发现原因是 android:fitsSystemWindows 属性 - 它似乎有点错误。
  • 所以你设置了这个属性还是什么?解决方案到底是什么?

标签: android android-layout android-dialog galaxy


【解决方案1】:

原来这是 android:fitsSystemWindows 和 Android Lollipop 的问题,就像在 this answer 中一样。

【讨论】:

    猜你喜欢
    • 2020-09-08
    • 2016-01-05
    • 1970-01-01
    • 2015-10-16
    • 2023-02-13
    • 1970-01-01
    • 2018-07-29
    • 2021-09-04
    • 1970-01-01
    相关资源
    最近更新 更多