fragment切换全屏和非全屏之间的切换

在使用fragment的时候,需要在通activity下的不同fragment之间切换,此时可能会需要在沉浸和非沉浸之间切换,但是在实操的时候发现,会出现非沉浸切换会沉浸的时候会有页面的抖动存在,视觉效果不理想.最后通过自定义一个跟状态栏高度相同的view占据视图最顶部,其他控件全部都处于该控件下方,这样就不需要进行切换了

override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
    var heightMeasureSpec2 = MeasureSpec.makeMeasureSpec(getStatusBarHeight(), MeasureSpec.EXACTLY)
    super.onMeasure(widthMeasureSpec, heightMeasureSpec2)
}

使用就直接用就行了,高度已经在自定义view中固定为状态栏的高度了

<com.zmkj.wltty.ui.StatusBarView
        android:id="@+id/statusbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        android:background="@color/headbg_color"/>
posted @   Mr`Chen`  阅读(146)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 【.NET】调用本地 Deepseek 模型
点击右上角即可分享
微信分享提示