【问题标题】:Layout not overing FragmentContainerView布局不超过 FragmentContainerView
【发布时间】:2020-05-28 14:37:18
【问题描述】:

我正在尝试在包含 FragmentContainerView 和 BottomNavbar 的布局上全屏显示 android:id="@+id/menu_layout" 以某种方式阻止它。上方工具栏部分有效。 我想实现全屏 android:id="@+id/menu_layout" 如果我让 FragmentContainerView android:layout_height="0dp" 它显示布局 这是我的xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Activities.MainActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/catchupColor"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme"
        app:layout_scrollFlags="scroll|enterAlways"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" >


        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/header_logo"/>



    </androidx.appcompat.widget.Toolbar>
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar_on_demand"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/catchupColor"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme"
        app:layout_constraintEnd_toEndOf="parent"
        android:visibility="gone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" >

        <TextView
            android:id="@+id/toolbarLogoText2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_gravity="center"
            android:drawableEnd="@drawable/keyboard_arrow_down_white_24x24"
            android:gravity="center"
            android:lineSpacingExtra="3.6sp"
            android:text="On Demand"
            android:textAllCaps="false"
            android:textColor="@color/white"
            android:textSize="18sp"
            android:visibility="visible" />

        <ImageView
            android:id="@+id/btn_filter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_gravity="end"
            android:layout_marginEnd="10dp"
            android:src="@drawable/ic_filter_list"
            android:visibility="visible" />

        <ImageView
            android:id="@+id/btn_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_gravity="start"
            android:layout_marginStart="10dp"
            android:src="@drawable/ic_icn_search"
            android:visibility="visible" />






    </androidx.appcompat.widget.Toolbar>

    <LinearLayout
        android:id="@+id/menu_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#BE000000"
        android:orientation="vertical"
        android:visibility="visible">

        <ImageView
            android:id="@+id/main_menu_img_close"
            android:layout_width="25dp"
            android:layout_height="25dp"
            android:layout_marginStart="14dp"
            android:layout_marginTop="14dp"
            android:src="@drawable/close" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_margin="15dp"
            android:gravity="center"
            android:orientation="vertical">


            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/main_menu_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center"
                android:layout_margin="20dp"
                android:foregroundGravity="center_vertical" />

        </LinearLayout>

    </LinearLayout>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/bottomNavigationView"
        android:layout_below="@+id/toolbar">

        <androidx.fragment.app.FragmentContainerView
            android:id="@+id/fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:defaultNavHost="true"
            app:navGraph="@navigation/mysat_nav">


        </androidx.fragment.app.FragmentContainerView>


    </RelativeLayout>


    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#020712"
        android:layout_alignParentBottom="true"
        android:theme="@style/BottomNavigationTheme"
        app:menu="@menu/bottom_menu">

    </com.google.android.material.bottomnavigation.BottomNavigationView>

【问题讨论】:

    标签: android layout


    【解决方案1】:

    尝试设置menu_layout 之类的高度

    android:elevation="10dp"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-27
      相关资源
      最近更新 更多