이번 시간에는 헤더 화면(header)을 만들어서 추가하는 방법에 대하여 알아보겠습니다.
NavigationView에 들어갈 header 화면입니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="190dp"
android:background="?attr/colorPrimary"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Header Title"
android:textSize="30sp"
android:textStyle="bold"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@android:color/white"/>
</LinearLayout>
- 설명 -
1. app:headerLayout
헤더 화면으로 사용할 파일을 적용합니다.
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_layout" />
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:fitsSystemWindows="true"
app:headerLayout="@layout/header_layout"
app:menu="@menu/drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
2022.06.29 - [안드로이드] - [안드로이드 코틀린] 큐알코드(QR CODE) 스캔하는 방법
2022.06.30 - [안드로이드] - [안드로이드 코틀린] 전화 걸기(Intent.ACTION_VIEW) 기능 만들어보기
2022.06.14 - [안드로이드] - [안드로이드 코틀린] Tab Custom Animation part1 - 화면 구성 및 설정
[안드로이드 코틀린] 다이얼로그(Dialog) 리스트(List)로 보여주는 방법 (0) | 2022.07.05 |
---|---|
[안드로이드 코틀린] DrawerLayout Navigaion 만드는 방법 part4 - 네비게이션 호출 메뉴 버튼 만들기 (0) | 2022.07.04 |
[안드로이드 코틀린] DrawerLayout Navigaion 만드는 방법 part2 - 메뉴 만들기 (0) | 2022.07.02 |
[안드로이드 코틀린] DrawerLayout Navigation 만드는 방법 part1 - 화면 만들기 (0) | 2022.07.01 |
[안드로이드 코틀린] 전화 걸기(Intent.ACTION_VIEW) 기능 만들어보기 (0) | 2022.06.30 |
댓글 영역