Navigation Drawer XML sample code

 

1. header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="176dp"
    android:background="#b1b1b1"
    android:gravity="bottom"
    android:orientation="vertical"
    android:padding="16dp">

    <ImageView
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:paddingTop="8dp"
        android:src="@mipmap/ic_launcher_round" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="My Navigation Drawer App"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="bold" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="subtitle here"
        android:textColor="@color/white"
        android:textSize="15sp" />
</LinearLayout>

 

 

2. row_item.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/item_row"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:background="#fff"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/relativeLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24dp"
        android:background="@drawable/item_bg"
        android:paddingBottom="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0"
        app:layout_constraintStart_toStartOf="parent">

        <TextView
            android:id="@+id/item_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="40dp"
            android:layout_marginTop="20dp"
            android:text="Simple Title Text"
            android:textColor="@color/title_text_color"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/item_timestamp"
            android:layout_width="280dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/item_title"
            android:layout_alignLeft="@+id/item_title"
            android:layout_marginTop="8dp"
            android:lineSpacingExtra="8dp"
            android:textColor="@color/content_text" />

        <ImageView
            android:id="@+id/item_bookmarkimage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="20dp"
            android:layout_marginRight="16dp"
            android:layout_toRightOf="@+id/item_timestamp"
            app:srcCompat="@drawable/ic_star"
            tools:ignore="VectorDrawableCompat" />

        <!-- 즐겨찾기 저장된 값 -->
        <TextView
            android:id="@+id/item_bookmark"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="invisible" />
    </RelativeLayout>

    <ImageView
        android:id="@+id/item_categoryimage"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="16dp"
        app:layout_constraintEnd_toStartOf="parent"
        app:layout_constraintStart_toStartOf="@+id/relativeLayout"
        app:layout_constraintTop_toTopOf="@+id/relativeLayout"
        app:srcCompat="@mipmap/ic_launcher_round" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

3. row_item.xml 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/text_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:text="타이틀" />

    <TextView
        android:id="@+id/text_timestamp"
        android:layout_below="@+id/text_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp"
        android:textColor="@android:color/black"
        android:text="작성일자" />

    <View
        android:layout_below="@+id/text_timestamp"
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:background="@android:color/darker_gray"
        />

    <TextView
        android:id="@+id/text_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"/>

    <TextView
        android:id="@+id/text_gubun"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="invisible"/>

</RelativeLayout>