daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.37k stars 2.67k forks source link

❓💥🔥 - Multiple Direction Swipe creating empty area #518

Open onuryurtturk opened 5 years ago

onuryurtturk commented 5 years ago

hi,

I implemented both direction ( - right & left ) like that

viewHolder.swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown); viewHolder.swipeLayout.addDrag(SwipeLayout.DragEdge.Left, viewHolder.swipeLayout.findViewById(R.id.left_view)); viewHolder.swipeLayout.addDrag(SwipeLayout.DragEdge.Right, viewHolder.swipeLayout.findViewById(R.id.right_view));

and my xml is like this

`<?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content">

<com.daimajia.swipe.SwipeLayout xmlns:swipe="http://schemas.android.com/apk/res-auto"
    android:id="@+id/swipe"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    swipe:leftEdgeSwipeOffset="0dp"
    swipe:rightEdgeSwipeOffset="0dp">

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="80dp"
        android:background="#FF5534"
        android:gravity="center"
        android:id="@+id/right_view"
        android:tag="Bottom3">

            <ImageView
                android:id="@+id/trash2"
                android:layout_width="27dp"
                android:layout_height="30dp"
                android:src="@drawable/trash" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Edit Item?"
                android:textColor="#fff"
                android:textSize="17sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="80dp"
        android:background="#FF5534"
        android:gravity="center"
        android:id="@+id/left_view"
        android:tag="Bottom3">

        <ImageView
            android:id="@+id/trash3"
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:src="@drawable/trash" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Edit Item?"
            android:textColor="#fff"
            android:textSize="17sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/item_selector"
        android:elevation="5dp"
        android:padding="10dp">

        <TextView
            android:id="@+id/position"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/text_data"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:tag="Hover"/>
    </LinearLayout>
</com.daimajia.swipe.SwipeLayout>

`

Everytime that I swipe to left after right swipe, its creating small empty area which is increasing by repeating left- right swiping step.

How can I prevent this?

device-2018-11-16-113009

ShoubhikBanerjee commented 5 years ago

Try this...

<LinearLayout android:layout_width="wrap_content" android:layout_height="80dp" android:background="#FF5534" android:gravity="center" android:id="@+id/right_view" android:tag="Bottom3">

        <ImageView
            android:id="@+id/trash2"
            android:layout_width="27dp"
            android:layout_height="30dp"
            android:src="@drawable/trash" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Edit Item?"
            android:textColor="#fff"
            android:textSize="17sp" />

</LinearLayout>``
onuryurtturk commented 5 years ago

@ShoubhikBanerjee already tried, not working.....

onuryurtturk commented 5 years ago

@ShoubhikBanerjee Can you try it with both direction? I'm not sure about requirement to add something to xml file

ShoubhikBanerjee commented 5 years ago

@onuryurtturk I am working too with both side swap.. it seems to be fine, although I am using TextView . Would you like have a look at my XML file?

onuryurtturk commented 5 years ago

yeap, it would be nice, could you please share with me?

ShoubhikBanerjee commented 5 years ago

`<?xml version="1.0" encoding="utf-8"?> <com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content"

android:id="@+id/swipe_list">
<!--app:clickToClose="true"-->

<LinearLayout
    android:tag="Bottom1"
    android:background="#66ddff00"
    android:id="@+id/bottom_wrapper"
    android:layout_width="160dp"
    android:weightSum="1"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/action1_1"
        android:textColor="#fff"
        android:text="Action1"
        android:layout_weight="0.5"
        android:gravity="center"
        android:clickable="true"
        android:background="@android:color/holo_green_light"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

        <TextView
            android:id="@+id/action_2"
            android:text="Action2"
            android:textColor="#fff"
            android:background="@android:color/holo_green_dark"
            android:gravity="center"
            android:layout_weight="0.5"
            android:layout_width="wrap_content"
            android:layout_height="match_parent" />
    </LinearLayout>

<LinearLayout
    android:tag="Bottom4"
    android:id="@+id/bottom_wrapper_2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/action_3"
        android:text="Action3"
        android:background="@android:color/darker_gray"
        android:gravity="center"
        android:layout_weight="0.5"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />

    <TextView
        android:id="@+id/acton_4"
        android:text="Action4"
        android:background="@android:color/holo_red_dark"
        android:gravity="center"
        android:layout_weight="0.5"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
</LinearLayout>

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp" android:background="@android:color/white" android:orientation="horizontal">

   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:background="@color/white"
       android:orientation="vertical">
       <TextView
           android:paddingLeft="10dp"
           android:paddingRight="10dp"
           android:paddingTop="10dp"
           android:background="@android:color/white"
           android:tag="Hover"
           android:text="Shoubhik Banerjee"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:id="@+id/tvName"/>

   </LinearLayout>

</LinearLayout>

</com.daimajia.swipe.SwipeLayout>`

ShoubhikBanerjee commented 5 years ago

And my JAVA code is as follows :

swipeLayout = (SwipeLayout)itemView.findViewById(R.id.swipe_list); swipeLayout.setShowMode(SwipeLayout.ShowMode.PullOut); swipeLayout.addDrag(SwipeLayout.DragEdge.Left, swipeLayout.findViewById(R.id.bottom_wrapper)); swipeLayout.addDrag(SwipeLayout.DragEdge.Right, swipeLayout.findViewById(R.id.bottom_wrapper_2));

onuryurtturk commented 5 years ago

Im getting java.lang.IllegalStateException: can not find SwipeLayout in target view error can you check it again?

onuryurtturk commented 5 years ago

device-2018-11-16-144303

onuryurtturk commented 5 years ago

@ShoubhikBanerjee also not working with your xml.

Follow these steps 1-) left swipe 2-) right swipe 3-) left swipe 4-) you got fucking white waste of area

so, another solution?

onuryurtturk commented 5 years ago

up

onuryurtturk commented 5 years ago

@daimajia up!

zain616 commented 5 years ago

Have you solved the problem yet?

onuryurtturk commented 5 years ago

Nope, I gave up to use multi directional concept @zain616

DK-UK commented 3 years ago

// you should add your bottom view within single layout like linear layout in below code check this out hope this will work for you!!

<com.daimajia.swipe.SwipeLayout xmlns:swipe="http://schemas.android.com/apk/res-auto" android:id="@+id/swipe" android:layout_width="match_parent" android:layout_height="wrap_content" swipe:leftEdgeSwipeOffset="0dp" swipe:rightEdgeSwipeOffset="0dp">

// BottomView <LinearLayout android:layout_width="200dp" android:layout_height="80dp" android:background="#FF5534" android:gravity="center" android:id="@+id/right_view" android:tag="Bottom3">

<RelativeLayout android:id="@+id/rel22" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="6dp" android:visibility="gone">

        <ImageView
            android:id="@+id/trash2"
            android:layout_width="27dp"
            android:layout_height="30dp"
            android:src="@drawable/trash" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Edit Item?"
            android:textColor="#fff"
            android:textSize="17sp" />

<RelativeLayout
    android:layout_width="200dp"
    android:layout_height="80dp"
    android:background="#FF5534"
    android:gravity="center"
    android:id="@+id/left_view"

android:visibility="gone" android:tag="Bottom3">

    <ImageView
        android:id="@+id/trash3"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:src="@drawable/trash" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Edit Item?"
        android:textColor="#fff"
        android:textSize="17sp" />

</RelativeLayout>

// Bottomview over here

// Surface view <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/item_selector" android:elevation="5dp" android:padding="10dp">

    <TextView
        android:id="@+id/position"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:id="@+id/text_data"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:tag="Hover"/>
</LinearLayout>

//surfaceview over here

</com.daimajia.swipe.SwipeLayout>

dont forget to setVisibility(Visible) in java file okay