日常bug汇总

1.constraintlayout + NestedScrollView 可能会导致NestedScrollView 不滑动

2.截屏 

open class SecureFragment : LogLifecycleFragment() {

    override fun onResume() {
        super.onResume()
        if (!BuildConfig.DEV) {
            requireActivity().window.setFlags(
                WindowManager.LayoutParams.FLAG_SECURE,
                WindowManager.LayoutParams.FLAG_SECURE
            )
        }
    }

    override fun onPause() {
        super.onPause()
        if (!BuildConfig.DEV) {
            requireActivity().window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
        }
    }
}

3.dialog设置消失动画

dialog_exit.xml文件类似如下。注意android:pivotX="1" 发现不生效


    
    

代码中dialog.window?.setWindowAnimations(R.style.DialogExitAnimation)

如果dialog中还有其他的style,可以这样

dialog = context?.let { Dialog(it, R.style.GuideDialogWindow) }

不受影响

4.dialog设置水平间距等不生效

dialog?.show()
dialog?.apply {
    window?.setLayout(
        WindowManager.LayoutParams.MATCH_PARENT,
        WindowManager.LayoutParams.WRAP_CONTENT
    )
}

你可能感兴趣的:(android)