From 7c361aefe02dd98b605607078204cd403bd72f25 Mon Sep 17 00:00:00 2001
From: Matthieu <24-artectrex@users.noreply.shinice.net>
Date: Sun, 13 Sep 2020 23:35:09 +0200
Subject: [PATCH] Add hamburger button to tab bar
---
.../java/com/h/pixeldroid/MainActivity.kt | 5 ++
.../main/res/drawable/ic_baseline_menu_24.xml | 10 ++++
app/src/main/res/layout/activity_main.xml | 48 +++++++++++++------
3 files changed, 48 insertions(+), 15 deletions(-)
create mode 100644 app/src/main/res/drawable/ic_baseline_menu_24.xml
diff --git a/app/src/main/java/com/h/pixeldroid/MainActivity.kt b/app/src/main/java/com/h/pixeldroid/MainActivity.kt
index 0edbbdc8..5f2826c9 100644
--- a/app/src/main/java/com/h/pixeldroid/MainActivity.kt
+++ b/app/src/main/java/com/h/pixeldroid/MainActivity.kt
@@ -8,6 +8,7 @@ import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageView
+import android.widget.Toolbar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import androidx.fragment.app.Fragment
@@ -88,6 +89,10 @@ class MainActivity : AppCompatActivity() {
}
private fun setupDrawer() {
+ main_toolbar.setNavigationOnClickListener {
+ drawer_layout.open()
+ }
+
header = AccountHeaderView(this).apply {
headerBackgroundScaleType = ImageView.ScaleType.CENTER_CROP
currentHiddenInList = true
diff --git a/app/src/main/res/drawable/ic_baseline_menu_24.xml b/app/src/main/res/drawable/ic_baseline_menu_24.xml
new file mode 100644
index 00000000..4350ba96
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_menu_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 12e2edb5..5613e72f 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -6,32 +6,50 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
- tools:openDrawer="start"
tools:context="com.h.pixeldroid.MainActivity">
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
-
-
-
+ app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
+ app:layout_constraintBottom_toTopOf="@+id/main_toolbar"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
-
+
+