Programming/Android
안드로이드 BottomNavigationView 아이콘 설정
JinWooHong Dev
2020. 1. 2. 17:11
1. res 폴더에 menu 폴더를 만들고 home.xml을 만든다.
2. home.xml 설정
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/homeItem"
android:icon="@drawable/baseline_home_black_24dp" //1번째 아이콘
android:title="Home"/>
<item
android:id="@+id/historyItem"
android:icon="@android:drawable/ic_menu_recent_history" //2번째 아이콘
android:title="History"/>
<item
android:id="@+id/userItem"
android:icon="@drawable/round_perm_identity_black_24dp" //3번째 아이콘
android:title="User"/>
</menu>
3. activity_main.xml 설정 (ConstraintLayout으로 설정해야한다)
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="parent"
app:menu="@menu/home" /> //메뉴 등록
4. BottonNavigationView 아이콘 설정 완료