Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DialogFragment conflict with gesture navigation

I have a Fullscreen Dialogfragment with a button in bottom-most part of the screen. In one plus 7 pro with gesture navigation enabled when we touch the lower-middle part of the "continue" button, the entire UI gets stuck other then toolbar. Navigation and everything still works.

enter image description here

Also when we click the button in bottom-middle part, the listener always triggers, so button click is happening, and if we minimize the app and reopen everything will start working again.

Style:-

<style name="FullScreenDialogStyle1" parent="AppTheme">
    <item name="android:windowLightStatusBar">true</item>
    <item name="colorPrimaryDark">@color/pure_white</item>
    <item name="android:navigationBarColor">@color/veryDarkBlue
    </item>

    <!-- Set this to true if you want Full Screen without status bar -->
    <item name="android:windowFullscreen">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>

    <!-- This is important! Don't forget to set window background -->
    <item name="android:windowBackground">@color/transparent</item>


    <!-- Additionally if you want animations when dialog opening -->
    <item name="android:windowEnterAnimation">@anim/slide_up</item>
    <item name="android:windowExitAnimation">@anim/slide_down</item>
</style>

Xml:-

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pure_white"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/pure_white"
    app:layout_constraintBottom_toTopOf="@id/calendar"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        app:navigationIcon="@drawable/ic_close_toolbar">

        <mobi.hubbler.app.views.SemiBoldTextView
            android:id="@+id/toolbar_title"
        style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:textSize="@dimen/hubbler_text_large"
            android:text="@string/date_time_select" />
    </androidx.appcompat.widget.Toolbar>

</com.google.android.material.appbar.AppBarLayout>


<FrameLayout
    android:id="@+id/calendar"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintBottom_toTopOf="@id/view"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/app_bar" />

<View
    android:id="@+id/view"
    android:layout_width="match_parent"
    android:layout_height="5dp"
    android:background="@color/slot_selection_divider_bg"
    app:layout_constraintBottom_toTopOf="@id/guideline6"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/calendar" />

<mobi.hubbler.app.views.BoldTextView
    android:id="@+id/timeSlotTitle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="@dimen/default_spacing_bw_views"
    android:text="Time Slot"
    android:textColor="@color/black"
    app:layout_constraintTop_toBottomOf="@id/guideline6" />

<androidx.constraintlayout.widget.Guideline
    android:id="@+id/guideline6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="0.6" />

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/time_list"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/timeSlotTitle"
    app:layout_constraintBottom_toTopOf="@id/submitButton"
    app:spanCount="3"
    tools:listitem="@layout/time_select_item" />




<Button
    android:id="@+id/submitButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/workflow_action_bg"
    android:text="@string/continue_text"
    android:textColor="@color/pure_white"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>
like image 562
Prateek Kumar Avatar asked Dec 04 '25 17:12

Prateek Kumar


1 Answers

WindowInsets tell the app where the system UI appears on top of your content, along with which regions of the screen System Gestures take priority over in-app gestures. Insets are represented by the WindowInsets class and WindowInsetsCompat class in Jetpack.You can use WindowInsetsCompat to have consistent behavior across all API levels.

System insets and mandatory system insets The following inset APIs are the most commonly used inset types:

System window insets: They tell you where the system UI is displayed over your app. We discuss how you can use system insets to move your controls away from the system bars.

System gesture insets: They return all gesture areas. Any in-app swipe controls in these regions can accidentally trigger System Gestures.

Mandatory gesture insets: They are a subset of the system gesture insets and can't be overridden. They tell you the areas of the screen where the behavior of the System Gestures will always take priority over in-app gestures.

Also, you can see this article.

like image 132
Amirhosein Heydari Avatar answered Dec 06 '25 06:12

Amirhosein Heydari