白羽
2018-07-24
来源 :网络
阅读 2157
评论 0
摘要:本文将带你了解Android编程之最强大的 Swipe Layout,希望本文对大家学Android有所帮助
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"
}
1234
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>
<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="//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>
<com.daimajia.swipe.SwipeLayout xmlns:android="//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.
}
});
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
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号