Android BottomNavigationView with DrawerLayout

사용 언어: Kotlin 1.8.10
사용 버전: Android Studio Electric Eel 2022.1.1 Patch 2

안드로이드 BottomNavigationView with DrawerLayout을 알아보겠습니다.


DrawerLayout과 BottomNavigationView를 같이 사용하면 이렇게 됩니다.
첫 메인 페이지에서만 Navigation Drawer을 사용할 수 있게 되는데요. 이걸 모든 첫 번째 페이지에서 활성화시켜 봅시다.






우선, 아랫글을 보고 Bottom Navigation을 사용합니다.



그리고 아랫글을 보고 Navigation Drawer를 사용합니다.




AppBarConfiguration을 사용해야 합니다.

lateinit var로 appBarConfiguration을 만듭니다.






AppBarConfiguration.Builder를 사용하여 BottomNavigationView의 처음 페이지들을 넣습니다.

이렇게 하면, 뒤로 가기 표시가 안 나옵니다.

저는 BottomNavigationView에 3 가지 항목이 있어서 아래에 3 가지 id가 들어갑니다.







여기 Configuration에 OpenableLayout을 추가해 줍니다.






NavigationUI.setupActionBarWithNavController의 3 번째 인자에 appBarConfiguration를 넣습니다.








onSupportNavigateUp()을 override 합니다.

여기에 NavigationUI.navigateUp()의 두 번째 인자에 appBarConfiguration을 넣어줍니다.







실행해 봅시다.





각 Bottom Navigation에서 Navigation Drawer이 잘 불러와지는 것을 볼 수 있습니다.



끝.


카테고리: Android

댓글

이 블로그의 인기 게시물

Python OpenCV 빈 화면 만들기

Python urllib.parse.quote()

Python bytes.fromhex()

Android AVD Ram size change

Forensics .pyc 파일 .py로 복구하기

Android Minimum touch target size

KiCad 시작하기 7 (FreeRoute 사용하기 2)

Android Notification with Full Screen

C++ OpenCV 모폴로지 침식, 팽창

KiCad 시작하기 2 (PCB 만들기)