공부방/Android

How to visible label of android BottomNavigationView (BottomNavigationView label 보이게 하는 방법)

soycrab 2019. 12. 9. 15:57

BottomNavigationView 를 사용할때 

버튼이 4개 이상 늘어나면 버튼의 이름 들이

선택 할 때만 보이게 된다. 

 

이럴때는 아래의 옵션

xml 에서 BottomNavigationView 에 아래의 옵션을 추가 하여 

BottomNavigationView의 이름 보기 방식을 변경할수 있다. 

app:labelVisibilityMode="labeled"

 

총 4개의 옵션이 있는데,

하나씩 설명해 보면

 

1. auto   

3 개 이하의 항목이있는 경우 레이블은 "레이블"으로 동작하거나 4 개 이상의 항목이 있으면 "선택된"레이블로 동작합니다.

즉 3개 이하의 메뉴일때는 이름이 그대로 보이고, 그 이상 일때는 선택된 버튼만 이름이 보인다. 

 

2. labeled

모든 항목의 이름이 전부 노출된다. 

 

3. unlabeled

이름이 노출되지 않는다. 

 

4. selected

선택된 항목의 이름만 노출 된다. 

 

 

 

 

 

참조 

https://developer.android.com/reference/com/google/android/material/bottomnavigation/LabelVisibilityMode

 

LabelVisibilityMode  |  Android Developers

LabelVisibilityMode public abstract @interface LabelVisibilityMode implements Annotation com.google.android.material.bottomnavigation.LabelVisibilityMode Label visibility mode enum for bottom navigation. The label visibility mode determines whether to show

developer.android.com

 

반응형