Search code examples
androidandroid-animationandroid-menuandroid-navigationview

Animation on items NavigationView - Android?


I have bellow menu :

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

    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_Search"
            android:icon="@drawable/search"
            android:title="@string/Search" />
        <item
            android:id="@+id/nav_Bookmark"
            android:icon="@drawable/sign"
            android:title="@string/Bookmark" />
    </group>

    <item android:title="">
        <menu>
            <item
                android:id="@+id/About_Software"
                android:icon="@android:drawable/ic_input_add"
                android:title="@string/About_Software" />
            <item
                android:id="@+id/nav_About"
                android:icon="@drawable/about_us"
                android:title="@string/About" />
            <item
                android:id="@+id/nav_help"
                android:icon="@drawable/help"
                android:title="@string/Help" />
            <item
                android:id="@+id/nav_Setting"
                android:icon="@drawable/settings"
                android:title="@string/Setting" />
            <item
                android:id="@+id/nav_Exit"
                android:icon="@drawable/exit"
                android:title="@string/Exit" />
        </menu>
    </item>

</menu>

And I use from this menu in :

<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="@dimen/Drawer_Width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@drawable/background_color"
    app:headerLayout="@layout/header_drawer"
    app:menu="@menu/menu_start_lowversion" />

Can I have animation on icon's menu or ripple on each items?


Solution

  • Try to add

    app:itemBackground="?attr/selectableItemBackground"

    to your navigation view xml for the ripple effect.

    I'm not sure what you mean by icon animation though. You can provide your own background selector if you want too.