Reputation: 1544
I have set up a BottomNavigationView
as follows:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@drawable/nav_item_color_state"
app:itemTextColor="@drawable/nav_item_color_state"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation"></android.support.design.widget.BottomNavigationView>
Functions getting called on BottomNavigationView
:
bottomNavigation.setOnNavigationItemSelectedListener(object: BottomNavigationView.OnNavigationItemSelectedListener {
override fun onNavigationItemSelected(item: MenuItem): Boolean {
return true
}
})
nav_item_color_state.xml
:
<?xml version="1.0" encoding="utf-8"?>
<item android:color="@android:color/white" android:state_enabled="true"/>
<item android:color="@color/colorPrimaryDark" android:state_enabled="false"/>
I have confirmed that animations are enabled both on the simulator and my device. The tutorials I have seen are getting animations. What am I doing wrong? After I click on one of the items on the BottomNavigationItem
, it suddenly shifts with no animation.
Upvotes: 0
Views: 762
Reputation: 1051
Try this
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/menu_timeline_selected" android:state_checked="true" />
<item android:drawable="@drawable/menu_timeline_selected" android:state_pressed="true" />
<item android:drawable="@drawable/menu_timeline_selected" android:state_selected="true" />
<item android:drawable="@drawable/menu_timeline_default" />
</selector>
Upvotes: 1