我使用 android studio 向導創建了一個新的底部導航活動。問題似乎是 activity_main 布局。片段視圖沒有延伸到螢屏頂部,而是被底部導航欄覆寫。
無論我做什么,我都無法將其向上移動。
這是 XML 代碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@ id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@ id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@ id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
uj5u.com熱心網友回復:
你需要設定
android:layout_width="0dp"
android:layout_height="0dp"
從“正常尺寸”切換到“應用約束尺寸”
uj5u.com熱心網友回復:
從根布局中洗掉以下填充:
android:paddingTop="?attr/actionBarSize"
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/324306.html
標籤:安卓 安卓工作室 android-fragments android-底部导航
上一篇:如何在片段內制作微調器?
