您的位置:首页 > 移动开发 > Android开发

AndroidSwipeLayout:最强大的 Swipe Layout

2015-10-10 17:41 513 查看

AndroidSwipeLayout是一个很强大的 Swipe Layout,和SwipeListView相比, 它不局限于ListView,点击图片观看效果

特性

轻松的整合ListView GridView ViewGroup
能回调 onOpen(), onUpdate
可以通知子元素
可以处理复杂的情况

下载

gradle

Java

dependencies {
compile 'com.android.support:support-v4:20.+'
compile "com.daimajia.swipelayout:library:1.1.7@aar"
}

1
2
3
4

dependencies
{

compile
'com.android.support:support-v4:20.+'
compile
"com.daimajia.swipelayout:library:1.1.7@aar"

}

maven

Java

<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
</dependency>
<dependency>
<groupId>com.daimajia.swipelayout</groupId>
<artifactId>library</artifactId>
<version>1.1.7</version>
<type>apklib</type>
</dependency>

1
2
3
4
5
6
7
8
9
10
11

<dependency>

<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>

<version>r6</version>
</dependency>

<dependency>
<groupId>com.daimajia.swipelayout</groupId>

<artifactId>library</artifactId>
<version>1.1.7</version>

<type>apklib</type>
</dependency>

使用例子





Java

<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="80dp">
<!-- Bottom View Start-->
<LinearLayout
android:background="#66ddff00"
android:id="@+id/bottom_wrapper"
android:layout_width="160dp"
android:weightSum="1"
android:layout_height="match_parent">
<!--What you want to show-->
</LinearLayout>
<!-- Bottom View End-->

<!-- Surface View Start -->
<LinearLayout
android:padding="10dp"
android:background="#ffffff"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--What you want to show in SurfaceView-->
</LinearLayout>
<!-- Surface View End -->
</com.daimajia.swipe.SwipeLayout>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

<com.daimajia.swipe.SwipeLayout
xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="80dp">
<!--
Bottom View Start-->

<LinearLayout
android:background="#66ddff00"

android:id="@+id/bottom_wrapper"
android:layout_width="160dp"

android:weightSum="1"
android:layout_height="match_parent">

<!--What
you want to
show-->
</LinearLayout>

<!--
Bottom View End-->

<!--
Surface View Start
-->

<LinearLayout

android:padding="10dp"
android:background="#ffffff"

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

<!--What
you want to
show in
SurfaceView-->
</LinearLayout>

<!--
Surface View End
-->
</com.daimajia.swipe.SwipeLayout>

Java

SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.sample1);

//set show mode.
swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);

//set drag edge.
swipeLayout.setDragEdge(SwipeLayout.DragEdge.Left);

swipeLayout.addSwipeListener(new SwipeLayout.SwipeListener() {
@Override
public void onClose(SwipeLayout layout) {
//when the SurfaceView totally cover the BottomView.
}

@Override
public void onUpdate(SwipeLayout layout, int leftOffset, int topOffset) {
//you are swiping.
}

@Override
public void onOpen(SwipeLayout layout) {
//when the BottomView totally show.
}

@Override
public void onHandRelease(SwipeLayout layout, float xvel, float yvel) {
//when user's hand released.
}
});

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

SwipeLayout
swipeLayout = (SwipeLayout)findViewById(R.id.sample1);

//set show mode.

swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);

//set drag edge.
swipeLayout.setDragEdge(SwipeLayout.DragEdge.Left);

swipeLayout.addSwipeListener(new
SwipeLayout.SwipeListener()
{

@Override
public
void onClose(SwipeLayout
layout)
{

//when the SurfaceView totally cover the BottomView.
}

@Override

public
void onUpdate(SwipeLayout
layout,
int leftOffset,
int topOffset)
{

//you are swiping.

}

@Override
public
void onOpen(SwipeLayout
layout)
{

//when the BottomView totally show.
}

@Override

public
void onHandRelease(SwipeLayout
layout,
float xvel,
float yvel)
{

//when user's hand released.

}
});

github网址 https://github.com/daimajia/AndroidSwipeLayout/wiki/usage
转载:http://hao.jobbole.com/androidswipelayout/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: