解决 Android Fragment 布局使用 fitsSystemWindows = true 无效

没有搜索到相关问题解答,故贴出来。
话不多说,解决方法很简单。
Fragment#onViewCreated 方法中使用如下语句

activity?.findViewById(android.R.id.content)?.getChildAt(0)?.let {
    ViewCompat.requestApplyInsets(it)
}

即可。

原理有机会再说。

你可能感兴趣的:(解决 Android Fragment 布局使用 fitsSystemWindows = true 无效)