개발 & 코딩/안드로이드 개발 팁
간단 DrawerLayout 사용법
강효재
2020. 7. 28. 19:45
1) DrawerLayout으로 감싼다
2) DrawerLayout 안쪽을 전체적으로 커버하는 Layout
3) NavigationView용도로 사용할 Layout (layout_gravity 값으로 start나 left를 줄 경우 왼쪽에서 생기며 end나 right를 줄 경우 오른쪽에서 생긴다.)
<?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/drawer_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".view.activity.MainTabAct">
<RelativeLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<LinearLayout
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#323145"
android:clickable="true"
android:fitsSystemWindows="false"
android:orientation="vertical">
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>
RelaytiveLayout이 2번에 해당되고 LinearLayout이 3번에 해당된다.