如何解决片段 (ScrollView) 覆盖底部 NavView 项目
我有一个带有 ScrollView 和 BottomNavBar 的 Fragment,从中可以使 Fragment 膨胀,但是编译时 ScrollView 覆盖了底部导航栏,使底部导航栏无法使用我如何将 Fragment 的内容限制为仅剩下屏幕的其余部分底部导航栏原样。
底部导航栏活动代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/landing_page_body"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".pages.LandingPage"
tools:openDrawer="start">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:transformPivotX="100dp"
app:labelVisibilityMode="unlabeled"
app:menu="@menu/bottom_navbar_menu"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/side_navbar_header"
app:menu="@menu/side_navbar_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
片段xml代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fragments.auction_add">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:paddingTop="20dp"
android:text="Enter Auction Details -"
android:textSize="40dp"></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingVertical="5dp">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"></ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:gravity="center"
android:paddingHorizontal="15dp"
android:paddingVertical="5dp">
<EditText
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_gravity="end"
android:background="@drawable/rounded_edittext"
android:gravity="center"
android:hint="Name of Item"
android:maxLines="1"
android:overScrollMode="ifContentScrolls" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingHorizontal="20dp"
android:paddingVertical="5dp">
<EditText
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@drawable/rounded_edittext"
android:gravity="center"
android:hint="Description"
android:maxLength="40"
android:maxLines="5"
android:minHeight="100dp"
android:overScrollMode="ifContentScrolls"
android:padding="5dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingVertical="5dp">
<EditText
android:layout_width="300dp"
android:layout_height="50dp"
android:background="@drawable/rounded_edittext"
android:gravity="center"
android:hint="Initial Price"
android:maxLines="1"
android:overScrollMode="ifContentScrolls" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:paddingVertical="5dp">
<EditText
android:id="@+id/startTimePicker"
android:layout_width="300dp"
android:layout_height="50dp"
android:background="@drawable/rounded_edittext"
android:gravity="center"
android:hint="Start Time"
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingVertical="5dp">
<EditText
android:id="@+id/endTimePicker"
android:layout_width="300dp"
android:layout_height="50dp"
android:background="@drawable/rounded_edittext"
android:gravity="center"
android:hint="End Time"
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginVertical="30dp"
android:gravity="center"
android:paddingVertical="5dp">
<Button
android:layout_width="200dp"
android:layout_height="50dp"
android:background="@drawable/rounded_edittext"
android:text="Post Item" />
</LinearLayout>
</LinearLayout>
</ScrollView>
输出 - Final Result of Above XML
解决方法
在Fragment xml代码中父线性布局的底部添加以下代码
<View
android:layout_width="match_parent"
android:layout_height="80dp">
</View>
希望它会起作用...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。