0

What I am trying to accomplish is basically having the icon move up a little bit when the icon is selected and move back down when another icon is selected in a BottomNavigationView. Almost like an animation indicating what fragment the user is on. I have tried adding padding when item is selected but instead it adds the padding to all of the icons.

Anyways this is my menu

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/navigation_home"
    android:icon="@drawable/ic_home"
    android:title=""/>

<item
    android:id="@+id/navigation_shop"
    android:icon="@drawable/ic_groceries"
    android:title=""/>

<item
    android:id="@+id/navigation_profile"
    android:icon="@drawable/ic_user"
    android:title=""/>

And my MainActivity

<RelativeLayout 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"
tools:context=".MainActivity">

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottomNavigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:paddingTop="8dp"
    android:layout_marginBottom="-8dp"
    android:background="@color/colorBlack"
    app:menu="@menu/navigation_bar"
    app:itemIconTint="@color/nav_item_color_selector"/>

Kristofer
  • 809
  • 9
  • 24

1 Answers1

1

You don't need to use padding or anything at all. Bottom Navigation View will do the job for you automatically Good Luck :)