QMUI_Android icon indicating copy to clipboard operation
QMUI_Android copied to clipboard

QMUIDialog在华为设置"显示大小"时显示错误

Open Del-Gin opened this issue 4 years ago • 3 comments

运行环境

  • [x] 设备型号:如:华为mate9、华为mate20、华为mate20X
  • [x] 设备系统版本:如 Android 10、android 9
  • [x] Gradle 版本:如 3.4.1
  • [x] QMUI Android 版本:1.4.4

具体问题描述

华为手机 - 系统设置 - 显示 - 将显示大小 设置为小 此时对话框显示异常,不显示按钮 但是当文案长到需要滚动时,按钮又可以正常显示了

builder.getTextView().setTextSize(12); 如果将字体缩小 还是如此

`

String AGREEMENT_TIP = "本协议向您说明:\n" + "1、为帮助您浏览推荐、发布信息、互动交流、注册认证,我们将会收集您的部分必要信息。\n" + "2、为提供上述服务,我们可能会收集联络方式、位置、通讯录等部分敏感信息,您有权拒绝或撤回授权。\n" + "3、未经您同意,我们不会从第三方获取、共享或提供您的信息。\n" + "4、如您同意,请点击下方按钮开始接受我们的服务。\n" + "前往查看完整版《用户协议》和《隐私政策》";

private void showAgreement() { SpannableString spannableString = new SpannableString(Constants.AGREEMENT_TIP); spannableString.setSpan(new ClickableSpan() { @Override public void onClick(@NonNull View widget) { ARouter.getInstance().build(RouterHub.WEB) .withBoolean(RouterHub.SWIPE_BACK, true) .withString("url", Constants.AGREEMENT_URL).navigation(GuideActivity.this); } }, Constants.AGREEMENT_TIP.length() - 12, Constants.AGREEMENT_TIP.length() - 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); spannableString.setSpan(new ClickableSpan() { @Override public void onClick(@NonNull View widget) { ARouter.getInstance().build(RouterHub.WEB) .withBoolean(RouterHub.SWIPE_BACK, true) .withString("url", Constants.AGREEMENT2_URL).navigation(GuideActivity.this); } }, Constants.AGREEMENT_TIP.length() - 5, Constants.AGREEMENT_TIP.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this).setTitle("用户协议和隐私政策").setMessage(spannableString)
        .addAction(0, "拒绝", QMUIDialogAction.ACTION_PROP_NEGATIVE, new ActionListener() {
            @Override
            public void onClick(QMUIDialog dialog, int index) {
                Utils.killApp();
            }
        })
        .addAction("确定", new ActionListener() {
                @Override
                public void onClick(QMUIDialog dialog, int index) {
                    Hawk.put(CacheKey.FIRST_RUN, false);
                    dialog.dismiss();
                    //点击即跳转
                    UserUtil.loginPoint();
                    com.dzwww.news.utils.Utils.jumpMain(GuideActivity.this);
                    finish();
                    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                }
            }
        ).setCancelable(false).setCanceledOnTouchOutside(false);

    QMUIDialog dialog = builder.create();
    builder.getTextView().setMovementMethod(LinkMovementMethod.getInstance());
    dialog.show();
}

`

问题截图

正常现象 image

异常现象 image

Layout Inspector 文件####

正常现象 https://share.weiyun.com/i8K4nhof 异常现象 https://share.weiyun.com/uhzoj5sN

异常日志(堆栈)

Del-Gin avatar Dec 29 '20 09:12 Del-Gin

正常现象图片 https://share.weiyun.com/BxHaMmza 异常现象图片 https://share.weiyun.com/Eb4YbHlq

Del-Gin avatar Dec 29 '20 09:12 Del-Gin

忘了说了 我对显示大小进行了一定的处理 BaseApplication和BaseActivity里面重写getResources方法 `private static int defDpi = 0;

@Override
public Resources getResources() {
    if (defDpi == 0) {
        try {
            Class WindowManagerGlobal = Class.forName("android.view.WindowManagerGlobal");
            Method getWindowManagerService = WindowManagerGlobal.getMethod("getWindowManagerService");
            getWindowManagerService.setAccessible(true);
            Object iwm = getWindowManagerService.invoke(WindowManagerGlobal);

            Method getInitialDisplayDensity = iwm.getClass().getMethod("getInitialDisplayDensity", int.class);
            getInitialDisplayDensity.setAccessible(true);
            defDpi = (int) getInitialDisplayDensity.invoke(iwm, Display.DEFAULT_DISPLAY);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
    Resources res = super.getResources();
    Configuration configuration = res.getConfiguration();
    boolean change = false;
    if (configuration.fontScale != 1) {
        change = true;
        configuration.fontScale = 1;
    }
    if (configuration.densityDpi != defDpi) {
        change = true;
        configuration.densityDpi = defDpi;
    }
    if (change) {
        res.updateConfiguration(configuration, res.getDisplayMetrics());
    }
    return res;
}`

主要是疑惑 为什么按钮出不来? 明明有空间显示

Del-Gin avatar Dec 30 '20 10:12 Del-Gin

哗伪是哄蒙啊 这框架是Android得,怎么可能兼容呢 哈哈哈哈

lhl-012 avatar Jan 21 '21 08:01 lhl-012