Android BottomNavigationView有奇怪的底部填充
我有一个带有底部导航的主布局和一些其他组件的片段。左边的片段是纵向的,这里的NavigationBottomView看起来不错,但在右侧片段上,方向设置为横向,底部还有一个填充。问题是如何在横向模式下删除navigationview底部的填充?第一个屏幕截图: 现在代码: main_activity.xmlAndroid BottomNavigationView有奇怪的底部填充,android,android-layout,Android,Android Layout,我有一个带有底部导航的主布局和一些其他组件的片段。左边的片段是纵向的,这里的NavigationBottomView看起来不错,但在右侧片段上,方向设置为横向,底部还有一个填充。问题是如何在横向模式下删除navigationview底部的填充?第一个屏幕截图: 现在代码: main_activity.xml <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayou
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:filterTouchesWhenObscured="true"
tools:context="pl.anwim.zcspa.activities.MainActivity">
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar_include"
app:navGraph="@navigation/nav_graph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/nav_host_fragment"
app:menu="@menu/role_dispatcher_menu" />
<include
android:id="@+id/toolbar_include"
layout="@layout/common_toolbar_hamburger"
app:layout_constraintBottom_toTopOf="@+id/nav_host_fragment"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
(左)对手\u站\u列表\u fragment.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/card_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
android:id="@+id/admin_card_list_refresh"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/card_list_title"
app:srl_direction="bottom">
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
android:id="@+id/admin_card_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="pl.anwim.mobile.v2.customer.activities.adminCard.AdminCardListFragment"
tools:listitem="@layout/opponent_station_list_row_fragment" />
</com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout>
<pl.anwim.zcspa.ui.component.CustomTextView
android:id="@+id/card_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="@string/no"
android:textAppearance="@style/Primary20BoldText"
app:ctv_backgroundColor="@color/colorTransparent"
app:ctv_iconColor="@color/colorPrimary"
app:ctv_iconDrawable="@drawable/ic_card"
app:ctv_iconPadding="@dimen/dp_15"
app:ctv_iconSize="@dimen/list_icon_size"
app:ctv_textColor="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/card_list_title">
<View
android:id="@+id/hline1"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:layout_toLeftOf="@+id/header1"
android:background="#000000" />
<TextView
android:id="@+id/header1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="10dp"
android:text="Filtrowanie"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold" />
<View
android:id="@+id/hline2"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/header1"
android:background="#000000" />
</RelativeLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rl1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/date_filter1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:gravity="center"
android:hint="Data od"
android:inputType="none"
android:textColor="@color/ms_black"
android:textSize="20sp" />
<EditText
android:id="@+id/date_filter2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/date_filter1"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:gravity="center"
android:hint="Data do"
android:inputType="none"
android:textColor="@color/ms_black"
android:textSize="20sp" />
</RelativeLayout>
<EditText
android:id="@+id/report_history_station_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:hint="Nazwa stacji"
android:textColor="@color/ms_black"
android:textSize="20sp" />
<CheckBox
android:id="@+id/report_history_proper_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:hint="Prawidłowość"
android:textColor="@color/ms_black"
android:textSize="20sp" />
</LinearLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Filtruj"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll2" />
<RelativeLayout
android:id="@+id/rl2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button">
<View
android:id="@+id/hline3"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:layout_toLeftOf="@+id/header2"
android:background="#000000" />
<TextView
android:id="@+id/header2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="10dp"
android:text="Filtrowanie"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold" />
<View
android:id="@+id/hline4"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/header2"
android:background="#000000" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorLightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/rl2" />
<pl.anwim.zcspa.ui.component.CustomTextView
android:id="@+id/card_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="@string/no"
android:textAppearance="@style/Primary20BoldText"
app:ctv_backgroundColor="@color/colorTransparent"
app:ctv_iconColor="@color/colorPrimary"
app:ctv_iconDrawable="@drawable/ic_card"
app:ctv_iconPadding="@dimen/dp_15"
app:ctv_iconSize="@dimen/list_icon_size"
app:ctv_textColor="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
(右)history_fragment.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/card_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
android:id="@+id/admin_card_list_refresh"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/card_list_title"
app:srl_direction="bottom">
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
android:id="@+id/admin_card_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="pl.anwim.mobile.v2.customer.activities.adminCard.AdminCardListFragment"
tools:listitem="@layout/opponent_station_list_row_fragment" />
</com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout>
<pl.anwim.zcspa.ui.component.CustomTextView
android:id="@+id/card_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="@string/no"
android:textAppearance="@style/Primary20BoldText"
app:ctv_backgroundColor="@color/colorTransparent"
app:ctv_iconColor="@color/colorPrimary"
app:ctv_iconDrawable="@drawable/ic_card"
app:ctv_iconPadding="@dimen/dp_15"
app:ctv_iconSize="@dimen/list_icon_size"
app:ctv_textColor="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@id/rl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/card_list_title">
<View
android:id="@+id/hline1"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:layout_toLeftOf="@+id/header1"
android:background="#000000" />
<TextView
android:id="@+id/header1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="10dp"
android:text="Filtrowanie"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold" />
<View
android:id="@+id/hline2"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/header1"
android:background="#000000" />
</RelativeLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rl1">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/date_filter1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:gravity="center"
android:hint="Data od"
android:inputType="none"
android:textColor="@color/ms_black"
android:textSize="20sp" />
<EditText
android:id="@+id/date_filter2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/date_filter1"
android:layout_weight="1"
android:focusableInTouchMode="false"
android:gravity="center"
android:hint="Data do"
android:inputType="none"
android:textColor="@color/ms_black"
android:textSize="20sp" />
</RelativeLayout>
<EditText
android:id="@+id/report_history_station_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:hint="Nazwa stacji"
android:textColor="@color/ms_black"
android:textSize="20sp" />
<CheckBox
android:id="@+id/report_history_proper_value"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:hint="Prawidłowość"
android:textColor="@color/ms_black"
android:textSize="20sp" />
</LinearLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Filtruj"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll2" />
<RelativeLayout
android:id="@+id/rl2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button">
<View
android:id="@+id/hline3"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_marginBottom="2dp"
android:layout_toLeftOf="@+id/header2"
android:background="#000000" />
<TextView
android:id="@+id/header2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginHorizontal="10dp"
android:text="Filtrowanie"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="bold" />
<View
android:id="@+id/hline4"
android:layout_width="fill_parent"
android:layout_height="5dip"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/header2"
android:background="#000000" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/history_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorLightGray"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/rl2" />
<pl.anwim.zcspa.ui.component.CustomTextView
android:id="@+id/card_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="@string/no"
android:textAppearance="@style/Primary20BoldText"
app:ctv_backgroundColor="@color/colorTransparent"
app:ctv_iconColor="@color/colorPrimary"
app:ctv_iconDrawable="@drawable/ic_card"
app:ctv_iconPadding="@dimen/dp_15"
app:ctv_iconSize="@dimen/list_icon_size"
app:ctv_textColor="@color/colorPrimary"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
如果你还需要知道什么,就告诉我。提前谢谢你 删除
app:layout\u constraintTop\u toBottomOf=“@id/nav\u host\u fragment”
底部导航(底部导航视图)
并添加固定高度android:layout\u height=“56dp”
根据需要更改56。您需要为底部导航视图指定特定高度。
在底部导航视图中使用此android:layout_height=“?attr/actionBarSize”您好,谢谢您的帮助,但这不是我看到的。我删除了app:layout_constraintTop_toBottomOf=“@id/nav_host_fragment”,并将高度更改为固定的BottomNavigationView,但没有效果:(