底部 LinearLayout 設置 alignParentBottom="true",想在其上方插入一個 View 將它頂起。
<RelativeLayout ...>
<!-- 內容區:match_parent 高度,底部留出底部欄高度 -->
<ScrollView
android:layout_above="@id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
</ScrollView>
<!-- 底部欄 -->
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
</LinearLayout>
</RelativeLayout>
layout_above="@id/bottom_bar" 而非固定高度。wrap_content 自適應高度。Visibility.GONE 內容區自動填滿。
app:layout_constraintBottom_toTopOf="@id/bottom_bar"
app:layout_constraintTop_toTopOf="parent"
更扁平、性能更好、可視化編輯友好。