从抽屉布局导航视图中删除波纹效果

问题描述 投票:0回答:1

我正在尝试从我的导航视图中删除this连锁反应,但没有任何运气。我尝试遵循我在 Stack 上找到的 BottomNavigationView - Shadow and Ripple EffectHow to disable Grayanimation from center to Edges on Bottom navigation on tap 问题的答案,但没有任何效果对我有用。这也是一个奇怪的行为,涟漪效应有时只会发生,通常是在导航菜单上单击两次之后,这可以在视频中看到。

这是我的 XML 文件:

<androidx.drawerlayout.widget.DrawerLayout
    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"
    android:id="@+id/drawer_layout"
    tools:openDrawer="start"
    tools:context=".HomeActivity">

    <com.google.android.material.navigation.NavigationView
        android:layout_width="275dp"
        android:layout_height="match_parent"
        android:id="@+id/navigation_view"
        app:itemIconPadding="10dp"
        app:itemHorizontalPadding="20dp"
        android:layout_gravity="start"
        android:fontFamily="@font/exo"
        android:textStyle="bold"
        app:headerLayout="@layout/navigation_header"
        app:menu="@menu/navigation_menu"
        app:itemBackground="@android:color/transparent"
        app:itemRippleColor="@android:color/transparent"
        app:itemIconTint="@color/moroccan_blue"
        app:itemTextColor="@color/moroccan_blue"
        android:backgroundTint="@color/white"
        app:drawerLayoutCornerSize="20dp"/>

</androidx.drawerlayout.widget.DrawerLayout>

我尝试添加

app:itemBackground="@android:color/transparent"
app:itemRippleColor="@android:color/transparent"
来解决这个问题,但没有成功。前者删除了之前的灰色波纹效果,并将其替换为视频中导航菜单的前两次点击中看到的透明波纹效果。在添加这些行之前我已经有相同的行为,唯一的区别是前两次点击是灰色的,其余的是视频中出现的粉红色。

java android drawerlayout navigationview ripple-effect
1个回答
0
投票

经过更多挖掘,我能够通过在

<item name="colorControlHighlight">@android:color/transparent</item>
文件中添加
themes.xml
来解决我的问题。我还在xml中的NavigationView中留下了以下参数:

app:itemBackground="@android:color/transparent"
app:itemRippleColor="@android:color/transparent"

现在,没有出现随机连锁反应。

© www.soinside.com 2019 - 2024. All rights reserved.