首页 > 解决方案 > 当我使用消失/可见时重新计算重量布局

问题描述

我有一个底部导航视图,我想隐藏它,然后在出现特定片段时显示它。

问题是,当我使用 Gone 和或 Visible 时,视图会重新计算,然后需要一段时间来更改片段并且它会弄乱顶部导航栏,因为它会由于重新计算而改变高度。

我应该使用什么样的布局来避免重新计算?

这是 axml :

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/internal_main_layout"
    android:background="@android:color/holo_red_light"
    android:orientation="vertical"
    android:minHeight="100dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <MyApp.Droid.Views.TopNavigation
        android:id="@+id/internal_top_navbar"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </MyApp.Droid.Views.TopNavigation >

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:layout_weight="8"
        android:layout_above="@+id/bottom_navigation"/>

    <Myapp.Droid.Views.BottomNavigation
        android:id="@+id/internal_bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
    </Myapp.Droid.Views.BottomNavigation >
  </LinearLayout>

是否有另一种方法可以响应并避免重新计算渲染?

标签: android

解决方案


推荐阅读