daimajia/AndroidSwipeLayout

โ“๐Ÿ’ฅ๐Ÿ”ฅ - Multiple Direction Swipe creating empty area

onuryurtturk opened this issue ยท 15 comments

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

`

<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

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>``

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

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

@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?

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

`
<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: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>`

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));

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

@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?

Have you solved the problem yet?

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

DK-UK commented

// 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

        <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

    <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