Tunous / SwipeActionView

Android swipe-able view, which allows users to perform actions with swipe gestures.
Apache License 2.0
196 stars 16 forks source link

Horisontal scroll not working inside SwipeActionView #22

Closed dec04 closed 4 years ago

dec04 commented 4 years ago

Hi @Tunous

How can I make an HorisontalScrollView work inside SwipeActionView. If i swipe any direction, scroll not work. I have a picture.

Not Work

Here's my code task_view.xml

<?xml version="1.0" encoding="utf-8"?>
<me.thanel.swipeactionview.SwipeActionView
    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/swipe_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:sav_swipeLeftRippleColor="@color/colorAccent"
    app:sav_swipeRightRippleColor="@color/colorPrimary" >

    <!-- First background view.
        It will be located on left side of the view and will allow users to perform
        right swipe gesture. -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:background="@color/colorPrimary"
        android:layout_width="80dp"
        android:layout_height="match_parent" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_alarm_add_24px"
            android:tint="@color/colorWhite"
            android:contentDescription="@string/content_description_add_alarm"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <!-- Second background view.
        This one will be located on the right side and allow users to perform
        left swipe gesture as its layout_gravity is changed to "end". -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:background="@color/colorAccent"
        android:layout_width="80dp"
        android:layout_height="match_parent"
        android:layout_gravity="end" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_delete_outline_24px"
            android:tint="@color/colorWhite"
            android:contentDescription="@string/delete_text"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <!-- Container.
        This is what users will see when the view is not being swiped. -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorWhite"
        android:padding="16dp">

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="20/08/2020"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="01:43:56"
            android:textSize="24sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView3" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Title of task"
            android:textSize="14sp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:text="Description of task"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView5" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView6">

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                    <com.google.android.material.chip.ChipGroup
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        app:singleLine="true">

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Home"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_primary"
                            app:rippleColor="@color/colorPrimary" />

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Work"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_accent"
                            app:rippleColor="@color/colorAccent" />

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Home"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_primary"
                            app:rippleColor="@color/colorPrimary" />

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Work"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_accent"
                            app:rippleColor="@color/colorAccent" />

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Home"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_primary"
                            app:rippleColor="@color/colorPrimary" />

                        <com.google.android.material.chip.Chip
                            style="@style/Widget.MaterialComponents.Chip.Choice"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:checkable="true"
                            android:checked="false"
                            android:text="Work"
                            android:textColor="@color/colorWhite"
                            app:chipBackgroundColor="@color/material_chips_state_accent"
                            app:rippleColor="@color/colorAccent" />

                    </com.google.android.material.chip.ChipGroup>

                </LinearLayout>
            </HorizontalScrollView>
        </LinearLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

</me.thanel.swipeactionview.SwipeActionView>
dec04 commented 4 years ago

@Tunous

Tunous commented 4 years ago

@dec04 I've published a pull request with a fix for this.

You can test it by pointing to the branch of the pull request in your build.gradle file:

implementation 'com.github.Tunous:SwipeActionView:th~22-horizontally-scrolling-child-SNAPSHOT'
dec04 commented 4 years ago

This works. Thanks.