Java 为什么我能';t使用渐变色android更改图标颜色和文本底部导航
我想让颜色像示例图像。但是我发现使用颜色渐变更改图标和文本时出现问题,因为底部导航中的属性只接受颜色。 请帮助我,上帝保佑你Java 为什么我能';t使用渐变色android更改图标颜色和文本底部导航,java,android,android-studio,android-layout,android-bottomnav,Java,Android,Android Studio,Android Layout,Android Bottomnav,我想让颜色像示例图像。但是我发现使用颜色渐变更改图标和文本时出现问题,因为底部导航中的属性只接受颜色。 请帮助我,上帝保佑你 我也在这样做,对于渐变图标,我使用了两幅图像。至于文本渐变,我仍在寻找一种方法 图标渐变: drawable/ic_home.xml:图标 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Icon active gradient -->
我也在这样做,对于渐变图标,我使用了两幅图像。至于文本渐变,我仍在寻找一种方法 图标渐变: drawable/ic_home.xml:图标
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Icon active gradient -->
<item android:drawable="@drawable/icon_home_active" android:state_pressed="true"/>
<item android:drawable="@drawable/icon_home_active" android:state_checked="true"/>
<!-- Icon default -->
<item android:drawable="@drawable/icon_home"/>
</selector>
另请参见此(处理状态)
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Icon active gradient -->
<item android:drawable="@drawable/icon_home_active" android:state_pressed="true"/>
<item android:drawable="@drawable/icon_home_active" android:state_checked="true"/>
<!-- Icon default -->
<item android:drawable="@drawable/icon_home"/>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home"
android:title="@string/title_home" />
....
</menu>
bottomNavView.setItemIconTintList(null);