1 year ago
#366439
shashank singh bisht
Motion layout on swipe is not working I have use tab view with view pager
I have created a bottom sheet with motion layout having default open 35% and in side that we have tabview and view pager and on Swipe of tabView I want that view pager height gone. But onSwipe is not working on touch of tab view. this is my Activity Screen XML file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout 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:nestedScrollingEnabled="true"
app:layoutDescription="@xml/fragment_property_map_view_scene"
tools:context=".maps.MapViewScreen">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/map_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
.......
</androidx.constraintlayout.widget.ConstraintLayout>
<Spinner
android:id="@+id/map_tabs_views_list"
android:layout_width="210dp"
android:layout_height="30dp"
android:layout_marginBottom="@dimen/dim_10"
android:background="@drawable/white_view_bar_bg"
app:layout_constraintBottom_toTopOf="@+id/property_map_view_guide_line_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageButton
android:id="@+id/map_add_note_btn"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="@dimen/dim_10"
android:background="@drawable/white_circle_bg"
android:padding="12dp"
android:scaleType="fitCenter"
android:src="@mipmap/add_note"
app:layout_constraintBottom_toBottomOf="@+id/map_tabs_views_list"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/slide_top"
android:layout_width="@dimen/dim_100"
android:layout_height="5dp"
android:layout_marginTop="@dimen/dim_10"
android:layout_marginBottom="@dimen/dim_10"
android:src="@drawable/slide_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/property_map_view_guide_line_1" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/map_tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/tab_unselect"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/slide_top"
app:tabBackground="@drawable/tab_selector"
app:tabIndicatorHeight="0dp"
app:tabSelectedTextColor="@color/black"
app:tabTextAppearance="@style/Theme.MapTabs"
app:tabTextColor="@color/grey_666666" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dim_0"
android:background="@color/white"
android:id="@+id/view_pager_container"
android:nestedScrollingEnabled="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/map_tabs" >
<androidx.viewpager.widget.ViewPager
android:id="@+id/map_tabs_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="true"
android:visibility="visible"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/property_map_view_guide_line_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dim_45"
app:layout_constraintTop_toBottomOf="@+id/property_map_view_guide_line_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/touchView"
android:elevation="@dimen/dim_1"
android:background="@android:color/transparent"/>
</androidx.constraintlayout.motion.widget.MotionLayout>
and here is my layoutDescription file xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="2000"
motion:motionInterpolator="linear">
<!-- <OnClick motion:clickAction="jumpToEnd" motion:targetId="@+id/map_add_note_btn" />-->
<OnSwipe motion:touchAnchorId="@id/map_tabs" motion:touchAnchorSide="bottom" motion:dragDirection="dragDown" motion:touchRegionId="@id/map_tabs"/>
<KeyFrameSet>
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/map_tabs_views_list"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="210dp"
android:layout_height="30dp"
android:visibility="visible"
motion:visibilityMode="ignore"
motion:layout_constraintBottom_toTopOf="@+id/property_map_view_guide_line_1"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/map_add_note_btn"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginEnd="15dp"
motion:visibilityMode="ignore"
android:layout_marginBottom="15dp"
motion:layout_constraintBottom_toTopOf="@+id/property_map_view_guide_line_1" />
<Constraint
android:id="@+id/slide_top"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="@dimen/dim_100"
android:layout_height="5dp"
motion:visibilityMode="ignore"
android:layout_marginBottom="@dimen/dim_10"
motion:layout_constraintTop_toBottomOf="@+id/property_map_view_guide_line_1"
motion:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="@dimen/dim_10" />
<Constraint
android:id="@+id/map_tabs"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="45dp"
motion:visibilityMode="ignore"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/slide_top" />
<Constraint
android:id="@+id/view_pager_container"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="0dp"
motion:visibilityMode="ignore"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/map_tabs"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/touchView"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="0dp"
motion:visibilityMode="ignore"
motion:layout_constraintTop_toBottomOf="@+id/property_map_view_guide_line_1"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintBottom_toTopOf="@+id/view_pager_container"/>
<!-- <Constraint-->
<!-- android:id="@+id/property_map_view_guide_line_1"-->
<!-- motion:layout_constraintGuide_percent="0.35"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <Constraint-->
<!-- android:id="@+id/property_map_view_guide_line_2"-->
<!-- motion:layout_constraintGuide_percent="1"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/map_tabs_views_list"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="210dp"
android:layout_height="30dp"
android:visibility="visible"
motion:visibilityMode="ignore"
motion:layout_constraintBottom_toTopOf="@+id/slide_top"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/map_add_note_btn"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="45dp"
android:layout_height="45dp"
motion:visibilityMode="ignore"
android:layout_marginEnd="15dp"
android:layout_marginBottom="15dp"
motion:layout_constraintBottom_toTopOf="@+id/property_map_view_guide_line_1" />
<Constraint
android:id="@+id/slide_top"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="@dimen/dim_100"
android:layout_height="5dp"
motion:visibilityMode="ignore"
android:layout_marginBottom="@dimen/dim_10"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintBottom_toTopOf="@+id/map_tabs"
android:layout_marginTop="@dimen/dim_10" />
<Constraint
android:id="@+id/map_tabs"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="45dp"
motion:visibilityMode="ignore"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintBottom_toBottomOf="parent"/>
<Constraint
android:id="@+id/view_pager_container"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="2dp"
motion:visibilityMode="ignore"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/map_tabs"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@+id/touchView"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="@dimen/dim_0"
motion:visibilityMode="ignore"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/map_tabs_views_list"
motion:layout_constraintStart_toStartOf="parent" />
<!-- <Constraint-->
<!-- android:id="@+id/property_map_view_guide_line_1"-->
<!-- motion:layout_constraintGuide_end="@dimen/dim_70"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
<!-- <Constraint-->
<!-- android:id="@+id/property_map_view_guide_line_2"-->
<!-- motion:layout_constraintGuide_end="@dimen/dim_70"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content" />-->
</ConstraintSet>
</MotionScene>
swipe is not working on the swipe of tabview. Thank you for your time
android
android-animation
android-constraintlayout
android-motionlayout
android-touch-event
0 Answers
Your Answer