0

I am using google material design bottom appbar with fragment navigation. I am not using NavigationIcon, but, when click on item, appear a back navigation arrow. How I can hide navigation ? This is principal activity xml, menu item are customized to show title with icons:

<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 app bar is created in onCreate activity Event:

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

Fragment are showed in click listener:

nav.navigate(R.id.verificationsfragment);

view screenshot:

before click verifications after click

Donald
  • 534
  • 1
  • 10
  • 18

2 Answers2

0

In your activity, try to add this line of code after setSupportActionBar :

getSupportActionBar.setDisplayHomeAsUpEnabled(false);

This should remove the back arrow button.

Hope it helps!

Gabriel
  • 464
  • 4
  • 17
  • This line not help. The only solution i've found is set bar.setNavigationIcon(null); in every transaction, but onclick produce a strange movement in icon items – Donald Mar 20 '20 at 18:13
  • ok. Did you also tried `getSupportActionBar().setHomeButtonEnabled(false);`? – Gabriel Mar 20 '20 at 18:17
0

finally I resolved with a BottomNavigationView inside a bottomnavigationBar, so I have BottomNavigation aspect, with floatinActionButtonIntegration, and BottomNavigationView funcionality.

Donald
  • 534
  • 1
  • 10
  • 18