상세 컨텐츠

본문 제목

[안드로이드 코틀린] DrawerLayout Navigaion 만드는 방법 part3 - 헤더 화면 만들기

안드로이드

by aries574 2022. 7. 3. 12:06

본문


이번 시간에는 헤더 화면(header)을 만들어서 추가하는 방법에 대하여 알아보겠습니다. 


목차

1. 실행 화면
2. 헤더 화면 만들기 header_layout.xml
3. 메인 화면 구현 activity_main.xml


1. 실행 화면


2. 헤더 화면 만들기 header_layout.xml

 - 설명 -

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>

 


3. 메인 화면 구현 activity_main.xml

- 설명 -

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) 스캔하는 방법

 

[안드로이드 코틀린] 큐알코드(QR CODE) 스캔하는 방법

이번 시간에는 큐알코드(QRCODE) 라이브러리를 추가해서 스캔하는 방법에 대하여 알아보겠습니다. 목차 1. 실행 화면 2. 라이브러리 등록 3. 권한 등록 4. 메인 화면 구성 activity_main.xml 5. 메

aries574.tistory.com

2022.06.30 - [안드로이드] - [안드로이드 코틀린] 전화 걸기(Intent.ACTION_VIEW) 기능 만들어보기

 

[안드로이드 코틀린] 전화 걸기(Intent.ACTION_VIEW) 기능 만들어보기

이번 시간에는 전화번호를 입력하고 버튼을 누르면 전화 거는 화면으로 이동하는 기능에 대하여 알아보겠습니다. 목차 1. 실행 화면 2. 메인 화면 구성 activity_main.xml 3. 메인 코드 구현 Main

aries574.tistory.com

2022.06.14 - [안드로이드] - [안드로이드 코틀린] Tab Custom Animation part1 - 화면 구성 및 설정

 

[안드로이드 코틀린] Tab Custom Animation part1 - 화면 구성 및 설정

앞으로 TabLayout을 직접 만들어 애니메이션 기능까지 넣어보도록 하겠습니다. 이번 시간에는 화면 구성 및 설정을 만들어 보겠습니다. 목차 1. 실행 화면 2. dataBinding 설정 build.gradle 3. 테마 변경 t

aries574.tistory.com

 

반응형

관련글 더보기

댓글 영역