AndroidSwipeLayout是一个很强大的 Swipe Layout,和SwipeListView相比, 它不局限于ListView,点击图片观看效果
特性
下载
gradle
1
2
3
4
|
dependencies
{
compile
'com.android.support:support-v4:20.+'
compile
"com.daimajia.swipelayout:library:1.1.7@aar"
}
|
maven
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
>
|
使用例子
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
>
|
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