How can i show part of View at first in DrawerLayout?

62 Views Asked by At

I'm using DrawerLayout now. I want to show a part of View in advance like below.

enter image description here

As you can see, we can see the part of View with android:layout_gravity="end". If i swipe from right to left, i can see the entire view.
enter image description here

The photos above are not real. I made them just to show you.

This below is what i made. activity_main.xml

<?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"
    tools:context=".MainActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
        
    </androidx.constraintlayout.widget.ConstraintLayout>

    <include
        android:id="@+id/drawerContent"
        layout="@layout/view_drawer_side_content"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_marginEnd="50dp"
        android:layout_gravity="end" />

</androidx.drawerlayout.widget.DrawerLayout>

view_drawer_side_content.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/atvDetailMobileSpecDrawerButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="C\nO\nN\nT\nE\nN\nT"
        android:textColor="@color/white"
        android:gravity="center"
        android:padding="10dp"
        android:textSize="24dp"
        android:background="@drawable/bg_rounded_left_12dp_gray333"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        tools:ignore="HardcodedText,SpUsage" />

    <View
        android:id="@+id/viewDetailMobileSpecDetailBorder1"
        android:layout_width="1dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="@id/inDetailMobileDrawerDeviceSpecGuide"
        app:layout_constraintBottom_toTopOf="@id/atvDetailMobileSpecDrawerButton"
        android:background="@color/grayd7" />

    <include
        android:id="@+id/inDetailMobileDrawerDeviceSpecGuide"
        layout="@layout/in_device_spec_guide_detail"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:elevation="3dp"
        app:layout_constraintStart_toEndOf="@id/atvDetailMobileSpecDrawerButton"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent" />

    <View
        android:id="@+id/viewDetailMobileSpecDetailBorder2"
        android:layout_width="1dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="@id/atvDetailMobileSpecDrawerButton"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@id/inDetailMobileDrawerDeviceSpecGuide"
        android:background="@color/grayd7" />

</androidx.constraintlayout.widget.ConstraintLayout>

But What i want to do are..
1. How can i show the part of View in advance?
2. I only want to show the entire view when i swipe the content textView area, not the entire right side.

is it possible?

0

There are 0 best solutions below