Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 안드로이드
- 다트
- Python
- 아마존 웹 서비스
- programers
- GDSC
- 파이썬
- 소프티어
- 현대sw
- 머신러닝
- aws
- java
- 스위프트
- MVVM
- Flutter
- VSCode
- 코테
- SWIFT
- 백준
- 알고리즘
- 자바
- baekjoon
- DART
- kotlin
- Android
- 플러터
- 코틀린
- softeer
- 개발
- 프로그래머스
Archives
- Today
- Total
조준장 개발자 생존기
[kotlin] 코틀린 Android Bottom Navigation Activity 뒤로가기시 앱 종료 본문
Develop/Kotlin
[kotlin] 코틀린 Android Bottom Navigation Activity 뒤로가기시 앱 종료
JunJangE 2021. 7. 24. 22:01이전에 Bottom Navigation Activity를 통해 앱을 구현할 때 뒤로가기를 누르게 되면 앱이 바로 종료 되었는데 어느 순간부터 뒤로가기 누르면 호스트 화면으로 이동하게 되었다.
구글링을 통해 알아본 결과 main_activity.xml에 코드 하나를 수정해야하는 것을 알게되었다.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu"
app:labelVisibilityMode="labeled"
android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar"/>
<!-- app:defaultNavHost="false" 뒤로가기 버튼 클릭시 호스트 화면으로 이동 true일 경우 NavHostFragment 로 이동 -->
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="false" <!-- 이 부분 -->
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
'Develop > Kotlin' 카테고리의 다른 글
[AWS] 아마존 웹 서비스 코틀린 Android + Amazon Cognito (0) | 2021.07.29 |
---|---|
[kotlin] 코틀린 Android Bottom Navigation View 생성 (0) | 2021.07.28 |
[kotlin] 코틀린 Android 네비게이션 바 아이콘 이름 고정 (0) | 2021.07.23 |
[kotlin] 코틀린 QR코드 스캐너 구현 (0) | 2021.07.03 |
[kotlin] 코틀린 스플래시 스크린(splash screen) 구현 (0) | 2021.07.03 |