BottomNavigationView标题的颜色为渐变色 [英] BottomNavigationView's titles' color being a gradient
本文介绍了BottomNavigationView标题的颜色为渐变色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使android中BottomNavigationView中的标题具有渐变颜色.
I need to make the titles in BottomNavigationView in android be of a gradient color.
<?xml version="1.0" encoding="utf-8"?>
<gradient xmlns:android="http://schemas.android.com/apk/res/android"
android:startColor="@color/gradientLeft"
android:endColor="@color/gradientRight"
android:angle="0"/>
我已经设置了颜色,并且可以与例如BtmNavView上的图标,但我无法获得将其颜色更改为渐变的标题.
I have the colors set up and it works with e.g. icons on BtmNavView, but I can't get the titles to change their color to a gradient.
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/btmNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="?attr/toolbarColor"
android:theme="@style/Widget.BottomNavigationView"
app:itemHorizontalTranslationEnabled="false"
app:itemTextColor="@drawable/test_gradient_colorstatelist"
app:layout_behavior="com.x.x.tools.BottomNavigationBehavior"
app:menu="@menu/bottom_nav" />
我也设置了一个选择器,但标题没有作用.
I have a selector set up too, but to no effect with the titles.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="@color/gradient" />
<item android:state_checked="true"
android:color="@color/gradient" />
<item android:color="@color/gradient" />
有什么主意如何将底部标题的颜色更改为渐变色?
Any ideas how can I change the color of the bottom titles to a gradient?
推荐答案
查看此问题的正确答案,可能会对您有所帮助:
See correct answer of this question, it may help you:
使用Kotlin语言为Android Studio中的文本设置渐变颜色
这篇关于BottomNavigationView标题的颜色为渐变色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文