Android 10 dialog 第一次创建时候抖动

您所在的位置:网站首页 view绘制导致dialog弹出动画卡顿 Android 10 dialog 第一次创建时候抖动

Android 10 dialog 第一次创建时候抖动

2024-06-08 10:22| 来源: 网络整理| 查看: 265

    android 5.0以后dialog 宽度不能全屏,需要我们动态设置。

WindowManager.LayoutParams layoutParams = this.getWindow().getAttributes(); layoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT; layoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;; this.getWindow().setAttributes(layoutParams);

设置以后在android 10 适配发现第一次创建dialog 会先小屏再全屏。最后定位原因,是给dialog 设置全屏的代码调用时机不对。

抖动是因为调用dialog 全屏放在了onShow方法中,在onCreate中调用可以解决抖动问题。

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // View contentView = getLayoutInflater().inflate(R.layout.include_exit_play, null); LogUtils.d(TAG, "onCreate: "); setContentView(R.layout.include_exit_play); ButterKnife.bind(this); WindowManager.LayoutParams layoutParams = this.getWindow().getAttributes(); layoutParams.width = Relat


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3