728x90
BottomNavigationView 혹은 NavigationView 등 menu 의 아이템을 가진 Layout 들의 아이템 색상을 변경할 수 있다.
app:itemIconTint
- 아이템의 아이콘 색상 지정
- xml 을 통해 check/uncheck 상태에 따라 색상을 나눌 수 있다.
app:itemTextColor
- 아이템의 글자 색상 지정
- xml 을 통해 check/uncheck 상태에 따라 색상을 나눌 수 있다.
Exam
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:itemIconTint="@color/colorCheck"
app:itemTextColor="@color/colorCheck"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="@menu/menu_bottom_navigation" />
아래의 xml 을 지정해주면 check/uncheck 상태에 따라 색상을 나눌 수 있다.
@color/colorCheck
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/red" android:state_checked="true" />
<item android:color="@color/black" android:state_checked="false" />
</selector>
728x90
'Android > 가끔식 필요한 코드들' 카테고리의 다른 글
[Kotlin] Unicode To String 변환 (0) | 2021.08.25 |
---|---|
[Android] Android Status bar 검은색 or 제거하기 (0) | 2021.04.09 |
[Android] Background를 투명하게 하려면.(BottomSheetDialogFragment) (0) | 2021.03.02 |
ViewPager - setOffscreenPageLimit(Fragment 의 생명주기 관리) (0) | 2020.12.13 |
RecyclerView - item 위치 찾기 (0) | 2020.12.08 |
댓글