0

我正在使用带有片段导航的谷歌材料设计底部应用程序栏。我没有使用 NavigationIcon,但是,当单击项目时,会出现一个后退导航箭头。如何隐藏导航?这是主要活动 xml,菜单项被定制为显示带有图标的标题:

<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">
        <fragment
            android:id="@+id/nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            app:defaultNavHost="true"
            app:layout_constraintBottom_toTopOf="@id/coordinatorLayout"
            app:layout_constraintEnd_toStartOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.0"
            app:navGraph="@navigation/mobile_navigation" />
        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:id="@+id/coordinatorLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent">

            <com.google.android.material.bottomappbar.BottomAppBar
                android:id="@+id/bottom_app_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                app:backgroundTint="@color/toolbarbackgroung"
                android:animateLayoutChanges="true"
                app:fabAlignmentMode="center"
                app:fabAnimationMode="slide"
                app:hideOnScroll="true">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <TextView
                        android:id="@+id/verificationscmd"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_marginStart="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:background="?android:attr/selectableItemBackground"
                        android:text="@string/title_verifications"
                        android:drawableTop="@drawable/ic_notifications"/>
                    <TextView
                        android:id="@+id/configurationcmd"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_marginStart="10dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:background="?android:attr/selectableItemBackground"
                        android:text="@string/title_config"
                        android:drawableTop="@drawable/ic_gear"/>


                </RelativeLayout>

            </com.google.android.material.bottomappbar.BottomAppBar>

            <com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/principalbutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/Widget.MaterialComponents.FloatingActionButton"
    app:backgroundTint="@color/primaryColor"
    app:elevation="8dp"
    app:fabCradleMargin="2dp"
    app:fabCradleRoundedCornerRadius="2dp"
    app:fabCustomSize="54dp"
    app:layout_anchor="@id/bottom_app_bar"
    app:maxImageSize="32dp"
    app:tint="@color/lightcolor"
    app:srcCompat="@drawable/ic_plus_symbol" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout></androidx.constraintlayout.widget.ConstraintLayout>

Bootm 应用栏在 onCreate 活动事件中创建:

bar = (BottomAppBar) findViewById(R.id.bottom_app_bar);
setSupportActionBar(bar);

片段显示在点击侦听器中:

nav.navigate(R.id.verificationsfragment);

查看截图:

点击验证之前 点击后

4

2 回答 2

0

最后我用一个底部导航栏中的底部导航视图解决了,所以我有底部导航方面,带有 floatinActionButtonIntegration 和底部导航视图功能。

于 2020-04-20T14:50:54.060 回答
0

在您的活动中,尝试在之后添加这行代码setSupportActionBar

getSupportActionBar.setDisplayHomeAsUpEnabled(false);

这应该删除后退箭头按钮。

希望能帮助到你!

于 2020-03-20T17:27:57.393 回答