Make the drawer layout adapt to any status bar size

This improves the drawer specifically for phones that have a notch.
This commit is contained in:
Mauricio Colli 2020-04-02 11:05:19 -03:00
parent da2b059802
commit 45194061b3
No known key found for this signature in database
GPG Key ID: F200BFD6F29DDD85
3 changed files with 20 additions and 18 deletions

View File

@ -1,24 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="@dimen/drawer_header_height" android:layout_height="wrap_content"
android:background="?colorPrimary" android:background="?colorPrimary"
android:nextFocusDown="@+id/drawer_header_action_button"> android:nextFocusDown="@+id/drawer_header_action_button">
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@drawable/background_header" android:src="@drawable/background_header"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/drawer_header_padding_top"
android:fitsSystemWindows="true"
android:gravity="bottom"
android:minHeight="@dimen/drawer_header_content_min_height"
android:orientation="vertical" android:orientation="vertical"
android:paddingTop="@dimen/drawer_header_padding_top"> app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -53,7 +59,8 @@
android:textStyle="bold" android:textStyle="bold"
app:autoSizeMaxTextSize="@dimen/drawer_header_newpipe_title_max_text_size" app:autoSizeMaxTextSize="@dimen/drawer_header_newpipe_title_max_text_size"
app:autoSizeMinTextSize="@dimen/drawer_header_newpipe_title_min_text_size" app:autoSizeMinTextSize="@dimen/drawer_header_newpipe_title_min_text_size"
app:autoSizeTextType="uniform" /> app:autoSizeTextType="uniform"
tools:ignore="UnusedAttribute" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -68,7 +75,7 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="32dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
@ -108,7 +115,8 @@
<Button <Button
android:id="@+id/drawer_header_action_button" android:id="@+id/drawer_header_action_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:background="?selectableItemBackground" android:background="?selectableItemBackground"
android:focusable="true" /> app:layout_constraintBottom_toBottomOf="parent"
</FrameLayout> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Menu Drawer Dimensions -->
<dimen name="drawer_header_height">150dp</dimen>
<dimen name="drawer_header_padding_top">36dp</dimen>
</resources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<!-- Menu Drawer Dimensions --> <!-- Menu Drawer Dimensions -->
<dimen name="drawer_header_height">130dp</dimen> <dimen name="drawer_header_content_min_height">120dp</dimen>
<dimen name="drawer_header_padding_top">16dp</dimen> <dimen name="drawer_header_padding_top">16dp</dimen>
<dimen name="drawer_header_newpipe_icon_size">48dp</dimen> <dimen name="drawer_header_newpipe_icon_size">48dp</dimen>
<dimen name="drawer_header_newpipe_icon_title_space">12dp</dimen> <dimen name="drawer_header_newpipe_icon_title_space">12dp</dimen>