J'ai une disposition de cadre dans l'activité. J'ai mis une barre d'action et une barre de navigation inférieure dans l'activité, mais le problème est que la disposition du cadre se trouve derrière la barre de navigation inférieure et qu'elle ne défile pas non plus. Je souhaite que la disposition du cadre reste toujours au-dessus de la barre de navigation inférieure.
J'ai essayé de donner au tiroir de navigation inférieur une hauteur fixe de "56dp", et layout_margin Bottom = "56dp". Cela fonctionne bien, mais je ne pense pas que ce soit une bonne solution, car dans certains cas, je souhaite masquer la barre de navigation inférieure.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_above="@+id/bottomNavi" android:background="#ff9800"></View> <android.support.design.widget.BottomNavigationView android:id="@+id/bottomNavi" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_gravity="bottom" android:background="@color/colorPrimary" app:itemIconTint="@color/botto_nav_color" app:itemTextColor="@color/botto_nav_color" app:menu="@menu/bottom_nav_menu"/> </RelativeLayout>
// Barre de navigation inférieure Code:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:background="#fafafa" android:orientation="vertical" tools:context=".Activities.Dashboard"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="@dimen/abc_action_bar_default_height_material" android:background="#ff2729c3" app:layout_scrollFlags="scroll|enterAlways" app:navigationIcon="@drawable/navigation_icon" app:theme="@style/AppTheme.Toolbar"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:layout_width="32dp" android:layout_height="32dp" android:src="@mipmap/app_logo" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginStart="38dp" android:layout_marginTop="4dp" android:fontFamily="cursive" android:text="LootBox" android:textColor="@color/white" android:textSize="22sp" android:textStyle="bold" /> <ImageView android:layout_width="24dp" android:layout_height="24dp" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" android:layout_marginTop="4dp" android:layout_marginEnd="56dp" android:src="@drawable/pin_posts" /> <include layout="@layout/notification_icon_count_badge" android:layout_width="24dp" android:layout_height="24dp" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" android:layout_marginTop="4dp" android:layout_marginRight="16dp" /> </RelativeLayout> </android.support.v7.widget.Toolbar> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="#ff9800" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.DrawerLayout android:id="@+id/myDrawer" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fragment_container_dashboard" android:layout_width="match_parent" android:layout_height="match_parent"/> <include layout="@layout/bottom_nav" /> <android.support.design.widget.NavigationView android:id="@+id/nav" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/colorPrimary" app:headerLayout="@layout/nav_header" app:itemBackground="@drawable/drawer_item_bg" app:itemIconTint="@color/white" app:itemTextColor="@color/white" app:menu="@menu/my_menu"> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout> </RelativeLayout> </LinearLayout>
Je veux que la disposition du cadre reste en dessous de la barre d'outils et au-dessus de la barre de navigation inférieure.
Mais ce qui se passe, c'est que la disposition du cadre est sous la barre d'outils, mais la disposition du cadre est derrière la barre de navigation inférieure.
4 Réponses :
Mon approche consisterait à envelopper la disposition de navigation inférieure que vous avez incluse dans un LinearLayout, puis à envelopper le FrameLayout et la nouvelle disposition contenant la barre de navigation inférieure dans une disposition relative, puis à positionner la disposition du cadre au-dessus de la disposition de la barre de navigation inférieure telle que:
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fragment_container_dashboard" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="56dp" android:layout_above="@id/bnve"/> <LinearLayout android:id="@+id/bnve" android:layout_width="match_parent" android:layout_height="wrap_content"> <include layout="@layout/bottom_nav" /> </LinearLayout> </RelativeLayout>
Alors où vais-je mettre ma disposition de tiroir?
La disposition du tiroir reste inchangée, il suffit d'envelopper la disposition du cadre et la barre inférieure dans une disposition relative comme je l'ai fait et de mettre cette disposition relative sous la disposition de votre tiroir
Essayez ceci:
<FrameLayout android:id="@+id/fragment_container_dashboard" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="56dp" android:layout_above="@+id/nav" /> <include android:id="@+id/nav" layout="@layout/bottom_nav" />
essayez de placer cette balise include au-dessus de Framelayout comme
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v4.widget.DrawerLayout android:id="@+id/myDrawer" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/bottom_nav" /> <FrameLayout android:id="@+id/fragment_container_dashboard" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="56dp" />
Désolé pour la réponse tardive. Pouvez-vous essayer ceci?
<include android:layout_alignParentBottom="true" android:layout_height="wrap_content" android:layout_width="wrap_content" layout="@layout/bottom_nav" />
que diriez-vous de déplacer votre code de mise en page séparé vers votre mise en page principale au lieu de l'inclure?
veuillez changer la position de la mise en page, en faire d'abord une barre de navigation, puis une mise en page du cadre
fragment_container_dashboard.bringToFront (); peut-être que cela vous aidera.