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进出动画-->
<style name="DialogExitAnimation" parent="android:Animation">
<item name="android:windowExitAnimation">@anim/dialog_exit</item>
</style>
dialog_exit.xml文件类似如下。注意android:pivotX="1" 发现不生效
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fillAfter="false">
<!-- 从左下角开始 -->
<scale
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="100%"
android:pivotY="0"
android:toXScale="0"
android:toYScale="0" />
</set>
代码中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
)
}