0

I've created a bottomNavigationView with floating action button and the items on bottom navigation bar act... weird after clicking them or holding them:

as you can notice there is a shadow around the "settings" button + that gray box appears

what should I change/disable to get rid of that "shadow" around the button after it's being clicked and that gray box (that appears after holding on the button)?

code:

  <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/bottomNavBar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/menu_final">

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_margin="2dp"
            android:clickable="true"
            android:focusable="true"
            android:foregroundGravity="clip_horizontal"
            android:theme="@style/fab"
            app:srcCompat="@drawable/ic_add" />
    </com.google.android.material.bottomnavigation.BottomNavigationView>

styles:

    <style name="fab" parent="Widget.Design.FloatingActionButton">
        <item name="android:backgroundTint">@color/white</item>
        <item name="tint">@color/black</item>
    </style>

    <style name="bottomNavBar" parent="Widget.Design.BottomNavigationView">
        <item name="android:background">@color/ground</item>
    </style>
icecube
  • 111
  • 2
  • 16
  • Please add what you have in style file for BottomNavigationView and FloatingActionButton – Abhilash Maurya Apr 06 '21 at 12:50
  • Just did that (sorry for latency) – icecube Apr 06 '21 at 16:29
  • For the people that got similar problem: setting up "colorControlHighlight" and "colorControlActivated" to "@android:color/transparent" removes that shadow, but I haven't figured out how to remove the " gray box" yet – icecube Apr 07 '21 at 20:27

2 Answers2

0

Try to set app:itemRippleColor="@null" or app:itemRippleColor="#0000" (transparent)

On Your bottom nav view

Narek Hayrapetyan
  • 1,731
  • 15
  • 27
0

I finally fixed it (It might not be the best solution but... it works)

to remove the shadow you just need to set the colorControlHighlight and colorControlActivated to "@android:color/transparent" to the bottomNavigationBar

to remove that box that appears after holding the button to the Activity add:

        bottomNavigationView.children.forEach {
            (it as? ViewGroup)?.children?.forEach {
                it.setOnLongClickListener { _ -> true }
            }
        }

source

icecube
  • 111
  • 2
  • 16