Skip to content
/ swipy Public

Android library to easily implement "swipable" views

License

Notifications You must be signed in to change notification settings

dotloop/swipy

Repository files navigation

drawing

Swipy is a simple and customizable solution to create "swipable" views

drawing

Binaries

In the build.gradle file of the root of your project, add

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
	}
}

In the build.gradle file of your app, add

dependencies {
   implementation "com.github.dotloop:swipy:1.0.0"
}

Sample

After defining the layout for the swipable view and the actions, you need to use the addDrag function to define which way they are swipable.

swipeLayout.addDrag(LEFT_EDGE, swipeLayout.findViewById(R.id.swipe_left_action))
swipeLayout.addDrag(RIGHT_EDGE, swipeLayout.findViewById(R.id.swipe_right_action))
<com.dotloop.swipy.SwipeLayout
    android:id="@+id/swipe_layout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/list_cell_height"
    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"
    >
    <LinearLayout
        android:id="@+id/swipe_left_action"
        android:layout_width="160dp"
        android:layout_height="match_parent"
        android:weightSum="1"
        >
        <TextView
            android:id="@+id/action1"
            android:layout_width="70dp"
            android:layout_height="50dp"
            android:text="Action 1"
            />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/swipe_right_action"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        >

        <ImageView
            android:id="@+id/action2"
            android:layout_width="70dp"
            android:layout_height="50dp"
            android:text="Action 2"
            />
    </LinearLayout>
    <TextView
        android:id="@+id/swipable_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        tools:text="Swipe me"
        />

</com.dotloop.swipy.SwipeLayout>

License

Copyright 2019 dotloop, Zillow Group

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.