BottomNavigationView 隨著點擊的 item 改變顏色 === 主要是下面兩個屬性,一個針對 icon 顏色,另一個是針對文字顏色,需要另外套用 `<selector>` 的客製化 ``` app:itemIconTint="@drawable/selector_bottom_nav_item" app:itemTextColor="@drawable/selector_bottom_nav_item" ``` * `selector_bottom_nav_item.xml` ```xml= <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:color="@color/red" /> <item android:color="@android:color/darker_gray" /> </selector> ``` * 我的 `BottomNavigationView` ```xml= ... <com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottomNav" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:labelVisibilityMode="labeled" app:itemIconTint="@drawable/selector_bottom_nav_item" app:itemTextColor="@drawable/selector_bottom_nav_item" app:menu="@menu/bottom_nav_menu"> </com.google.android.material.bottomnavigation.BottomNavigationView> ... ``` * 效果(因保護個資碼掉介面部分)   ## Ref. [Selected tab's color in Bottom Navigation View](https://stackoverflow.com/a/40326245) ###### tags: `Bottom Navgation`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up