查阅了很多资料,还是没有找到解决办法。正如您在下面的 git 上看到的,当您点击按钮导航图标时,它从中心到边缘有灰色动画。有没有办法禁用这个动画?
灰色动画 这是我的 XML
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@android:color/white"
app:elevation="0dp"
app:itemIconTint="@color/bottomNavigationIconColor"
app:itemTextColor="@drawable/nav_item_text_color_state"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation_main" />
和 nav_item_text_color_state
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="false"
android:color="@color/bottomNavigationIconColor" />
<item
android:state_checked="true"
android:color="#005EFF" />
</selector>
更新 找到了解决方案。要禁用此灰色波纹效果,只需将
app:itemBackground="@null"
添加到 xml。
找到了解决方案,只需将
app:itemBackground="@null"
添加到 xml 即可。
使用
app:itemRippleColor="@color/your_color"
设置自定义颜色以获得点击效果,或使用 app:itemRippleColor="@null"
设置无效果
将 app:itemBackground 设置为 null 现在不起作用。
新方法是:
app:itemBackground="@android:color/transparent"
上面的代码都不适合我。如果您也遇到这种情况,请尝试以下操作:
app:itemActiveIndicatorStyle="@null"
app:itemBackground="@android:color/transparent"