microsoftarchive / android-sliding-layer-lib

Highly customizable SlidingLayer as you have seen in Wunderlist
http://wunderlist.com
Apache License 2.0
932 stars 279 forks source link

horizontal scroll inside a vertical sliding layout #118

Open symphonyrecords opened 5 years ago

symphonyrecords commented 5 years ago

In my XML I have a horizontal recyclerview wrapped by this custom class.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/video_cutter_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/videoview_bg"
    android:orientation="vertical"
    tools:ignore="RtlHardcoded">

    <RelativeLayout
        android:id="@+id/layout_surface_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/layout"
        android:background="@android:color/transparent"
        android:gravity="center"
        android:orientation="vertical">

        <com.devbrackets.android.exomedia.ui.widget.VideoView
            android:id="@+id/video_loader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" />

        <ImageView
            android:id="@+id/icon_video_play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/play_button"
            android:contentDescription="@null" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="72dp"
        android:background="?attr/video_timeline_bg">

        <RelativeLayout
            android:id="@+id/timeText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/textTimeStart"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginStart="7dp"
                android:layout_marginLeft="7dp"
                android:gravity="left"
                android:text="@string/timer2" />

            <TextView
                android:id="@+id/textTime"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                android:text="@string/timer2"
                android:textColor="?attr/color_accent" />

            <TextView
                android:id="@+id/textTimeEnd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginEnd="7dp"
                android:layout_marginRight="7dp"
                android:layout_toEndOf="@+id/textTime"
                android:layout_toRightOf="@+id/textTime"
                android:gravity="right"
                android:text="@string/timer2" />

        </RelativeLayout>

        <androidx.appcompat.widget.AppCompatSeekBar
            android:id="@+id/handlerTop"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:max="1000"
            android:paddingTop="30dp"
            android:progressDrawable="@android:color/transparent"
            android:secondaryProgress="0"
            android:thumb="@drawable/vector_apptheme_text_select_handle_middle" />

        <View
            android:id="@+id/lineTop"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_below="@+id/handlerTop"
            android:background="@color/line_button" />

    </RelativeLayout>

    <com.symphonyrecords.mediacomp.slidinglayer.SlidingLayer xmlns:slidingLayer="http://schemas.android.com/apk/res-auto"
        android:id="@+id/slider_panel"
        android:layout_width="match_parent"
        android:layout_height="400dip"
        android:layout_below="@+id/layout_surface_view"
        android:layout_gravity="bottom"
        android:gravity="bottom"
        slidingLayer:openLayer="false"
        slidingLayer:stickTo="bottom">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="400dip"
            android:background="@color/slider_panel_color_trans98">

            <TextView
                android:id="@+id/added_clips_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginTop="7dp"
                android:padding="7dp"
                android:text="Selected 0 clips"
                android:textColor="?attr/text_color"
                android:textSize="@dimen/sp12"
                android:textStyle="bold" />

            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/slider_iv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_gravity="top|center"
                android:background="?attr/selectableItemBackgroundBorderless"
                android:contentDescription="@null"
                android:padding="7dp"
                android:tint="?attr/color_accent"
                app:srcCompat="@drawable/vector_slide_down" />

            <Button
                android:id="@+id/btAdd"
                style="@style/BorderlessButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:gravity="center"
                android:shadowColor="?attr/textview_shadow"
                android:shadowDx="@integer/shadowDx"
                android:shadowDy="@integer/shadowDy"
                android:shadowRadius="@integer/shadowRadius"
                android:text="@string/add"
                android:textColor="?attr/color_accent"
                android:textSize="@dimen/sp14"
                android:textStyle="bold" />

            <Button
                android:id="@+id/btNext"
                style="@style/BorderlessButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/btAdd"
                android:gravity="center"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"
                android:shadowColor="?attr/textview_shadow"
                android:shadowDx="@integer/shadowDx"
                android:shadowDy="@integer/shadowDy"
                android:shadowRadius="@integer/shadowRadius"
                android:text="@string/next"
                android:textColor="?attr/color_accent"
                android:textSize="@dimen/sp14"
                android:textStyle="bold" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/mRecyclerView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/btAdd"
                android:background="@color/slider_panel_color_trans98"
                android:scrollbarSize="@dimen/scrollbar_size"
                android:scrollbarStyle="outsideInset"
                android:scrollbarThumbHorizontal="?attr/color_accent"
                android:scrollbars="horizontal" />

        </RelativeLayout>

    </com.symphonyrecords.mediacomp.slidinglayer.SlidingLayer>

</RelativeLayout>

So I have a horizontal scroll(recyclerview), inside a vertical slide(stickTo bottom).

The problem is this, please look at the below GIF file:

horizontal scroll inside vertical slide

As you can see I can't scroll in recyclerview properly.

Do you have any suggestions?

symphonyrecords commented 5 years ago

If anybody have the same issue this is how I solved it.

In SlidingLayer.java class inside onInterceptTouchEvent method add below code for MotionEvent.ACTION_MOVE action:

if (xDiff > yDiff) {
    return false;
}

It'll look like:

switch (action) {
    case MotionEvent.ACTION_MOVE:
        .
        .
        .

        if (xDiff > yDiff) {
            return false;
        }

        if (validHorizontalDrag || validVerticalDrag) {
            mIsDragging = true;
            setDrawingCacheEnabled(true);
        }

        break;

    .
    .
    .