charles工具抓包教程(http跟https)

1.下载charles 可以去charles官网下载,下载地址:http://www.charlesproxy.com/download/ 根据自己的操作系统下载对应的版本,然后进行安装,然后打开charles工具 2.设置代理(记住手机跟电脑要在同一个网络,用的同一个路由器) 1).查看默认端口 Proxy->Proxy Settings 在这个页面会看到HTTP Proxy的默认端口是8888 我们不需要修改,只需要知道有这个值就行 2).查看当前电脑的ip 例如我这里的是:192.168.9.129 3).知道了默认端口跟ip地址,我们就可以手机上设置代理了。设置步骤我录制了gif动画。(我用的是genymotion模拟器,真机也是一样的) 完成了以上两个步骤就可以抓到http请求的数据了,效果图如下: 接下来讲解如何抓取https协议的包,如果你没有这个需求,请不要继续浏览下面的内容 3.设置charles ssl代理 Proxy->SSL Proxy Settings 弹出一个ssl代理设置界面 1).Enable SSL Proxying复选框打上勾 2).添加你想要的设置代理的域名,端口默认443 设置过后效果图如下: 4.手机下载ssl证书 1).Help->SSL Proxying ->Install Charles Root Certificate on a Mobile Device or Remote Browser… 会弹出一个提示框,如下显示: 浏览器输入这个地址即可下载证书,记住要用Android自带的浏览器. 地址是:http://charlesproxy.com/getssl 扫一扫二维码安装ssl 2).然后按照他的提示安装证书即可. 做完第三步跟第四步就可以抓包https数据了.如果还有问题请留言。。。下面是我抓包截图。 方法二 HTTP包: 1.安装抓包工具 Charles , 到官网http://www.charlesproxy.com/可下载到最新版本 2.用安装了charles的电脑,代理待抓包anroid手机的网络连接: 首先查看pc的网络IP地址;打开手机设置,进入当前wifi连接,设置代理为手动,将服务器填为上一步中获得的IP,端口默认为8888(在charles的proxy setting中可以改这个端口号)。这时Charles弹出确认框,点击Allow按钮即可 3.中文乱码问题解决 在charles的content/info.plist 中 的vmoption 添加-Dfile.encoding=UTF-8 HTTPS抓包: 下载Charles证书http://www.charlesproxy.com/ssl.zip,解压后导入到手机中,然后设置->安全->凭据存储->从存储设备安装,选中证书。 在Charles的工具栏上点击设置按钮,选择Proxy Settings;切换到SSL选项卡,选中Enable SSL Proxying,选项卡的Locations表单可以填写要抓包的域名和端口,点击Add按钮,在弹出的表单中Host填写域名,比如填api.instagram.com,Port填443。默认的..表示应用于所有地址

2016年7月19日 · 1 分钟 · 天边的星星

在低版本android系统上实现Material design应用

Material Design真的很好看,动画效果真的很实用。前面也写了一些文章介绍如何编写Material风格的程序,但是很多都是一些新的api,低版本上面没有这些api,我们没办法使用。但是不用气馁,google官方,以及一些大牛,给我们提供了一些程序,让我们在低版本上面可以实现Material风格的程序,这里就给大家介绍一下。 妹子图截屏 使用support library 使用support library最新的版本,appcomt21,可以在较低版本上面实现部分风格,在之前的文章我已经说过了,这里在系统的说一下。 应用主题 这部分的话之前的文章说过,链接在这里: http://blog.isming.me/2014/10/18/creating-android-app-with-material-design-one-theme/ 使用gralde进行构建的话,在依赖中添加v7包: [?](http://www.open-open.com/lib/view/open1416277425289.html#) <table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="gutter"> <div class="line number1 index0 alt2"> 1 </div> <div class="line number2 index1 alt1"> 2 </div> <div class="line number3 index2 alt2"> 3 </div> <div class="line number4 index3 alt1"> 4 </div> <div class="line number5 index4 alt2"> 5 </div> </td> <td class="code"> <div class="container"> <div class="line number1 index0 alt2"> `dependencies {` </div> <div class="line number2 index1 alt1"> `compile ``'com.android.support:appcompat-v7:21.0.+'` </div> <div class="line number3 index2 alt2"> `compile ``'com.android.support:cardview-v7:21.0.+'` </div> <div class="line number4 index3 alt1"> `compile ``'com.android.support:recyclerview-v7:21.0.+'` </div> <div class="line number5 index4 alt2"> `}` </div> </div> </td> </tr> </table> 使用eclipse构建的话,加入最新的appcompat包即可。 ...

2016年1月5日 · 5 分钟 · 天边的星星

Material Designer的低版本兼容实现——View & Animation

Material Designer 宗旨:让不同大小不同用途的设备上拥有同一种设计风格 1.纸张 这种设计模式大量参考了纸墨的模式,将空间变得像纸张一样,而用户的手指就是毛笔。用户按到控件上就会产生墨晕效果。这样的好处是明确的告诉用户是否点击了控件,而且还能让用户一下子明白控件的布局思路。毕竟一张一张的纸叠加起来的控件是很容易让人接受的。这里还有一个词“引喻”,虽然控件像纸张,但是它具有变大变小,改变颜色等能力,所以完全可以不用拘泥于现实纸张。 2.深度 新的设计中希望所有的控件都是现实世界中的隐喻,比如你按下按钮,按钮就应该有被按下的状态,这里就要用到了涟漪(Ripple)效果了。其实涟漪效果是来表示你手指按上去后墨晕扩散的效果的,下面的图能很明白的说明这点。 3.动画 动画贯穿于Material Designer之中,官方文档中用了很大的篇幅来讲解动画效果,希望让设计的动画效果很美观。但我个人认为为了动画而动画是完全不可取的,比如下面的例子 这里的动画看起来十分自然和美观,但是在实际中用户切换activity是很常见的,如果经常出现这个动画用户会觉得“很腻”,十分不友好。动画其实是一个画龙点睛的东西,万不可变为画蛇添足。那么,上图的这个动画应该在什么时候使用呢?用在第一次用户进入一个新的界面的时候,我们为了凸显这个界面的某种特定功能,就可以让这个功能的图标动起来,表现出一个点我试试的效果。 4.排版 新的设计里面很在意排版,里面列出了很多详细的数据来支持我们的设计。对于留白也有了详细的说明。优秀的排班会让你的应用看起来干净,优雅,这点十分重要。在之后的文章中我也会多少说到这方面的知识。 设计文档(不用FQ) http://design.1sters.com/ http://www.ui.cn/Material/ 目录 Material Designer的低版本兼容实现(二)—— Theme{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(三)——Color{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(四)—— ToolBar{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(五)—— ActivityOptionsCompat{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(六)—— Ripple Layout{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(七)—— Rectange Button{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(八)—— Flat Button{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(九)—— Float Button & Small Float Button{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(十)—— CheckBox & RadioButton{#cb_post_title_url.postTitle2} Material Designer的低版本兼容实现(十一)—— Switch{#cb_post_title_url.postTitle2} ...

2016年1月5日 · 1 分钟 · 天边的星星

Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片的优缺点比较

在android中的加载网络图片是一件十分令人头疼的事情,在网上有着许多关于加载网络图片的开源库,可以让我们十分方便的加载网络图片。在这里我主要介绍一下我自己在使用Volley, Picasso, Universal-Imageloader的一些使用的感悟。以及最基本的用法介绍。 1.android-Volley 给ImageView设置图片源 - > // imageView是一个ImageView实例 - > // ImageLoader.getImageListener的第二个参数是默认的图片resource id - > // 第三个参数是请求失败时候的资源id,可以指定为0 - > ImageListener listener = ImageLoader.getImageListener(imageView, android.R.drawable.ic_menu_rotate, android.R.drawable.ic_delete); - > mImageLoader.get(url, listener); 复制代码 使用NetworkImageView Volley提供了一个新的控件NetworkImageView来代替传统的ImageView,这个控件的图片属性可以通过 - > mImageView.setImageUrl(url, imageLoader) 复制代码 来设定。而且,这个控件在被从父控件detach的时候,会自动取消网络请求的,即完全不用我们担心相关网络请求的生命周期问题。 - > mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache()); - > &#8230;. &#8230; - > - > if(holder.imageRequest != null) { - > holder.imageRequest.cancel(); - > } - > holder.imageRequest = mImageLoader.get(BASE_UR + item.image_url, holder.imageView, R.drawable.loading, R.drawable.error); - > 复制代码 总结:如果你的工程项目,是一个比较小的项目,或者要求不是很高的项目,处理比较简单的可以使用这个库,这个库是Google 2013 I/O 发布的一个开源库。使用这个库在图片的处理上,没有提供任何的图片处理的操作,个人感觉这个库主要在网络数据连接上比较好,在图片处理上还是不够完善,强大。 ...

2015年11月5日 · 2 分钟 · 天边的星星

直接拿来用!十大Material Design开源项目

** **本文详细介绍了十个Material Design开源项目,从示例、FAB、菜单、动画、Ripple到Dialog,看被誉为“Google第一次在设计语言和规范上超越了Apple”的Material Design是如何逐渐成为App的一种全新设计标准。 介于拟物和扁平之间的Material Design自面世以来,便引起了很多人的关注与思考,就此产生的讨论也不绝于耳。本文详细介绍了在Android开发者圈子里颇受青睐的十个Material Design开源项目,从示例、FAB、菜单、动画、Ripple到Dialog,看被称为“Google第一次在设计语言和规范上超越了Apple”的Material Design是如何逐渐成为App的一种全新设计标准。 1. MaterialDesignLibrary 在众多新晋库中,MaterialDesignLibrary可以说是颇受开发者瞩目的一个控件效果库,能够让开发者在Android 2.2系统上使用Android 5.0才支持的控件效果,比如扁平、矩形、浮动按钮,复选框以及各式各样的进度指示器等。 ![](http://dl2.iteye.com/upload/attachment/0103/5584/80416adf-b40f-31f9-b2e0-3986c8ab7790.jpg) 除上述之外,MaterialDesignLibrary还拥有SnackBar、Dialog、Color selector组件,可非常便捷地对应用界面进行设置。 进度指示器样式效果设置: Xml代码 <embed src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" type="application/x-shockwave-flash" width="14" height="15"> </embed> </div> - <span class="tag"><</span><span class="tag-name">com.gc.materialdesign.views.ProgressBarCircularIndetermininate</span> - <span class="attribute">android:id</span>=<span class="attribute-value">&#8220;@+id/progressBarCircularIndetermininate&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;32dp&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;32dp&#8221;</span> - <span class="attribute">android:background</span>=<span class="attribute-value">&#8220;#1E88E5&#8221;</span> <span class="tag">/></span> Dialog: Java代码 <embed src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" type="application/x-shockwave-flash" width="14" height="15"> </embed> </div> - Dialog dialog = <span class="keyword">new</span> Dialog(Context context,String title, String message); - dialog.show(); 2. RippleEffect ...

2015年7月10日 · 3 分钟 · 天边的星星

List of Android UI/UX Libraries

A curated list of awesome Android UI/UX libraries. {#user-content-other-lists.anchor}Other lists Looking for Core Library? Check out wasabeef/awesome-android-libraries. Looking for iOS? Check out cjwirth/awesome-ios-ui {#user-content-mantainers.anchor}Mantainers wasabeef ogaclejapan {#user-content-index-light-weight-pages.anchor}Index (light-weight pages) Material Layout Button List / Grid ViewPager Label / Form Image SeekBar Progress Menu ActionBar Dialog Calendar Graph Animation Parallax Effect (Blur… etc) Other {#user-content-material.anchor}Material Name <th> License </th> <th> Demo </th> [MaterialDesignLibrary](https://github.com/navasmdc/MaterialDesignLibrary) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary2.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary3.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary3.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary4.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary4.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary5.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary5.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary6.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary6.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary7.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary7.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary8.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary8.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary9.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary9.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary10.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary10.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary11.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary11.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary12.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary12.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary13.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary13.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDesignLibrary14.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDesignLibrary14.png) </td> [DrawerArrowDrawable](https://github.com/ChrisRenke/DrawerArrowDrawable) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/DrawerArrowDrawable.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/DrawerArrowDrawable.gif) </td> [MaterialTabs](https://github.com/neokree/MaterialTabs) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialTabs.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialTabs.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialTabs2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialTabs2.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialTabs3.jpeg)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialTabs3.jpeg) </td> [PagerSlidingTabStrip](https://github.com/jpardogo/PagerSlidingTabStrip) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/PagerSlidingTabStrip.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/PagerSlidingTabStrip.gif) </td> [material-ripple](https://github.com/balysv/material-ripple) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-ripple.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-ripple.gif) </td> [RippleEffect](https://github.com/traex/RippleEffect) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RippleEffect.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RippleEffect.gif) </td> [LDrawer](https://github.com/ikimuhendis/LDrawer) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/LDrawer.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/LDrawer.gif) </td> [material-design-icons](https://github.com/google/material-design-icons) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-design-icons.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-design-icons.png) </td> [AndroidMaterialDesignToolbar](https://github.com/tekinarslan/AndroidMaterialDesignToolbar) <td> UnKnown </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AndroidMaterialDesignToolbar.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AndroidMaterialDesignToolbar.gif) </td> [MaterialEditText](https://github.com/rengwuxian/MaterialEditText) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialEditText.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialEditText.png) </td> [material-menu](https://github.com/balysv/material-menu) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-menu.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-menu.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-menu2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-menu2.gif) </td> [material-dialogs](https://github.com/afollestad/material-dialogs) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-dialogs.webp)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-dialogs.webp) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-dialogs2.webp)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-dialogs2.webp) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-dialogs3.webp)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-dialogs3.webp) </td> [AlertDialogPro](https://github.com/fengdai/AlertDialogPro) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AlertDialogPro.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AlertDialogPro.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AlertDialogPro2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AlertDialogPro2.png)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AlertDialogPro3.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AlertDialogPro3.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AlertDialogPro4.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AlertDialogPro4.png) </td> [MaterialNavigationDrawer](https://github.com/neokree/MaterialNavigationDrawer) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialNavigationDrawer.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialNavigationDrawer.png) </td> [MaterialDialog](https://github.com/drakeet/MaterialDialog) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDialog.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDialog.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/MaterialDialog2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/MaterialDialog2.png) </td> [materialish-progress](https://github.com/pnikosis/materialish-progress) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/materialish-progress.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/materialish-progress.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/materialish-progress2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/materialish-progress2.gif) </td> [FloatingActionButton](https://github.com/makovkastar/FloatingActionButton) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/FloatingActionButton.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/FloatingActionButton.gif) </td> [android-floating-action-button](https://github.com/futuresimple/android-floating-action-button) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/android-floating-action-button.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/android-floating-action-button.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/android-floating-action-button.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/android-floating-action-button.png) </td> [snackbar](https://github.com/nispok/snackbar) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/snackbar.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/snackbar.png) </td> [CircularReveal](https://github.com/ozodrukh/CircularReveal) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/CircularReveal.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/CircularReveal.gif) </td> [material-range-bar](https://github.com/oli107/material-range-bar) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-range-bar.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-range-bar.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-range-bar2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-range-bar2.png) </td> [Lollipop-AppCompat-Widgets-Skeleton](https://github.com/sachin1092/Lollipop-AppCompat-Widgets-Skeleton) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/LollipopAppCompatWidgetSkeleton.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/LollipopAppCompatWidgetSkeleton.gif) </td> [Carbon](https://github.com/ZieIony/Carbon) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> NONE </td> [material-calendarview](https://github.com/prolificinteractive/material-calendarview) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/material-calendarview.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/material-calendarview.gif) </td> [Material](https://github.com/rey5137/material) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material2.gif)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material3.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material3.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material4.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material4.gif)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material5.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material5.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material6.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material6.gif)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material7.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material7.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material8.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material8.gif)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material9.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material9.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material10.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material10.gif)[![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Material11.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Material11.png) </td> {#user-content-layout.anchor}Layout Name License Demo WaveView Apache License V2 ResideLayout Apache License V2 AndroidSwipeLayout MIT FreeFlow Apache License V2 SwipeBackLayout Apache License V2 Maskable Layout Apache License V2 ExpandableLayout MIT android-PullRefreshLayout MIT TileView MIT ShowcaseView Apache License V2 Ultra Pull To Refresh Apache License V2 AndroidViewHover UnKnown DraggablePanel Apache License V2 Slidr Apache License V2 Phoenix Pull-to-Refresh Apache License V2 Pull-to-Refresh.Tours Apache License V2 InboxLayout UnKnown SwipeBack UnKnown ArcLayout Apache License V2 Dragger Apache License V2 PhysicsLayout Apache License V2 BottomSheet License Bubbles for Android Apache License V2 AndroidSlidingUpPanel Apache License V2 android-transition Apache License V2 {#user-content-button.anchor}Button Name License Demo circular-progress-button Apache License V2 android-process-button Apache License V2 android-circlebutton Apache License V2 android-flat-button Apache License V2 MovingButton MIT LabelView Apache License V2 {#user-content-list–grid.anchor}List / Grid Name <th> License </th> <th> Demo </th> [SuperRecyclerView](https://github.com/Malinskiy/SuperRecyclerView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> NONE </td> [RecyclerViewSwipeDismiss](https://github.com/CodeFalling/RecyclerViewSwipeDismiss) <td> UnKnown </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerViewSwipeDismiss.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerViewSwipeDismiss.gif) </td> [FlabbyListView](https://github.com/jpardogo/FlabbyListView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/FlabbyListView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/FlabbyListView.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/FlabbyListView2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/FlabbyListView2.gif) </td> [recyclerview-stickyheaders](https://github.com/eowise/recyclerview-stickyheaders) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/recyclerview-stickyheaders.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/recyclerview-stickyheaders.gif) </td> [ParallaxListView](https://github.com/Gnod/ParallaxListView) <td> UnKnown </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/ParallaxListView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/ParallaxListView.gif) </td> [PullZoomView](https://github.com/Frank-Zhu/PullZoomView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/PullZoomView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/PullZoomView.gif) </td> [SwipeMenuListView](https://github.com/baoyongzhang/SwipeMenuListView) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/SwipeMenuListView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/SwipeMenuListView.gif) </td> [discrollview](https://github.com/flavienlaurent/discrollview) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/discrollview.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/discrollview.gif) </td> [StickyListHeaders](https://github.com/emilsjolander/StickyListHeaders) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/StickyListHeaders.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/StickyListHeaders.gif) </td> [ListBuddies](https://github.com/jpardogo/ListBuddies) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/ListBuddies.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/ListBuddies.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/ListBuddies.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/ListBuddies.gif) </td> [Android-ObservableScrollView](https://github.com/ksoichiro/Android-ObservableScrollView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView2.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView3.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView3.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView4.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView4.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView5.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView5.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView6.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView6.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView7.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView7.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView8.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView8.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView9.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView9.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView10.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView10.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView11.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView11.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView12.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView12.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/Android-ObservableScrollView13.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/Android-ObservableScrollView13.gif) </td> [AsymmetricGridView](https://github.com/felipecsl/AsymmetricGridView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AsymmetricGridView.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AsymmetricGridView.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AsymmetricGridView2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AsymmetricGridView2.png) </td> [DynamicGrid](https://github.com/askerov/DynamicGrid) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/DynamicGrid.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/DynamicGrid.gif) </td> [AndroidStaggeredGrid](https://github.com/etsy/AndroidStaggeredGrid) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AndroidStaggeredGrid.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AndroidStaggeredGrid.png) </td> [SwipeListView](https://github.com/47deg/android-swipelistview) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/android-swipelistview.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/android-swipelistview.png) </td> [android-parallax-recyclerview](https://github.com/kanytu/android-parallax-recyclerview) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/android-parallax-recyclerview.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/android-parallax-recyclerview.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/android-parallax-recyclerview2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/android-parallax-recyclerview2.gif) </td> [BlurStickyHeaderListView](https://github.com/emmano/BlurStickyHeaderListView) <td> [MIT](http://opensource.org/licenses/MIT) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/BlurStickyHeaderListView.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/BlurStickyHeaderListView.gif) </td> [RecyclerView Animators](https://github.com/wasabeef/recyclerview-animators) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/recyclerview-animators.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/recyclerview-animators.gif) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/recyclerview-animators2.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/recyclerview-animators2.gif) </td> [RecyclerView-FlexibleDivider](https://github.com/yqritc/RecyclerView-FlexibleDivider) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerView-FlexibleDivider.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerView-FlexibleDivider.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerView-FlexibleDivider2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerView-FlexibleDivider2.png) </td> [AndroidTreeView](https://github.com/bmelnychuk/AndroidTreeView) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AndroidTreeView.webp)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AndroidTreeView.webp) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/AndroidTreeView2.webp)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/AndroidTreeView2.webp) </td> [RecyclerViewFastScroller](https://github.com/danoz73/RecyclerViewFastScroller) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerViewFastScroller.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerViewFastScroller.png) [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerViewFastScroller2.png)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerViewFastScroller2.png) </td> [RecyclerView-MultipleViewTypesAdapter](https://github.com/yqritc/RecyclerView-MultipleViewTypesAdapter) <td> [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0) </td> <td> [![](https://github.com/wasabeef/awesome-android-ui/raw/master/art/RecyclerView-MultipleViewTypesAdapter.gif)](https://github.com/wasabeef/awesome-android-ui/blob/master/art/RecyclerView-MultipleViewTypesAdapter.gif) </td> {#user-content-viewpager.anchor}ViewPager Name License Demo ParallaxPagerTransformer UnKnown ViewPagerTransforms Apache License V2 CircleIndicator MIT Android ViewPagerIndicator Apache License V2 Android-ParallaxHeaderViewPager Apache License V2 freepager Apache License V2 SpringIndicator Apache License V2 SmartTabLayout Apache License V2 FlipViewPager.Draco Apache License V2 MaterialViewPager Apache License V2 {#user-content-label–form.anchor}Label / Form Name License Demo Shimmer-android Apache License V2 Shimmer for Android BSD 2 License Titanic Apache License V2 MatchView Apache License V2 android-autofittextview Apache License V2 SecretTextView UnKnown TextJustify-Android Apache License V2 RoundedLetterView Apache License V2 TextDrawable Apache License V2 BabushkaText Apache License V2 ExpandableTextView Apache License V2 Float Labeled EditText Apache License V2 SizeAdjustingTextView GNU License NONE {#user-content-image.anchor}Image Name License Demo TouchImageView LICENSE NONE CircleImageView Apache License V2 android-shape-imageview Apache License V2 GifImageView MIT cropper Apache License V2 android-crop Apache License V2 SelectableRoundedImageView Apache License V2 RoundedImageView Apache License V2 CropImageView Apache License V2 {#user-content-seekbar.anchor}SeekBar Name License Demo DiscreteSeekBar Apache License V2 {#user-content-progress.anchor}Progress Name License Demo SmoothProgressBar Apache License V2 NumberProgressBar MIT CircleProgress UnKnown android-square-progressbar UnKnown GoogleProgressBar Apache License V2 Android-RoundCornerProgressBar Apache License V2 ElasticDownload Apache License V2 FABProgressCircle Apache License V2 {#user-content-menu.anchor}Menu Name License Demo CircularFloatingActionMenu MIT AndroidResideMenu MIT Folder-ResideMenu Apache License V2 Side-Menu.Android Apache License V2 Context-Menu.Android Apache License V2 GuillotineMenu-Android Apache License V2 {#user-content-actionbar.anchor}ActionBar Name License Demo FadingActionBar Apache License V2 GlassActionBar Apache License V2 NotBoringActionBar Apache License V2 {#user-content-dialog.anchor}Dialog Name License Demo DialogPlus Apache License V2 Sweet Alert MIT {#user-content-calendar.anchor}Calendar Name License Demo Caldroid MIT android-times-square Apache License V2 Android-MonthCalendarWidget Apache License V2 android-betterpickers Apache License V2 Android-Week-View Apache License V2 SilkCal MIT SublimePicker Apache License V2 MaterialDateTimePicker Apache License V2 CompactCalendarView MIT {#user-content-graph.anchor}Graph Name License Demo EazeGraph Apache License V2 hellocharts-android Apache License V2 MPAndroidChart Apache License V2 WilliamChart Apache License V2 {#user-content-animation.anchor}Animation Name License Demo AndroidViewAnimations MIT ListViewAnimations Apache License V2 AndroidImageSlider MIT transitions-everywhere Apache License V2 Android Ripple Background MIT android-flip MIT FragmentTransactionExtended Apache License V2 KenBurnsView Apache License V2 rebound BSD 2 License http://facebook.github.io/rebound/ Reachability Apache License V2 AnimationEasingFunctions MIT EasyAndroidAnimations UnKnown android-pathview Apache License V2 ViewRevealAnimator Apache License V2 ArcAnimator MIT SearchMenuAnim UnKnown Cross View Apache License V2 {#user-content-parallax.anchor}Parallax Name License Demo ParallaxEverywhere MIT {#user-content-effect.anchor}Effect Name License Demo EtsyBlur Apache License V2 BlurDialogFragment Apache License V2 BlurBehind MIT Android StackBlur Apache License V2 EdgeEffectOverride Apache License V2 {#user-content-other.anchor}Other Name License Demo Swipecards Apache License V2 Android-Bootstrap MIT Android PDFView GPL V3 Dspec Apache License V2 LolliPin Apache License V2 DrawableView Apache License V2 Material Shadow 9-Patch Apache License V2 SimpleFingerGestures Apache License v2 Decor Apache License V2 Voice Recording Visualizer Apache License V2 EasyFonts Apache License V2 转自:https://github.com/wasabeef/awesome-android-ui ...

2015年7月9日 · 5 分钟 · 天边的星星

让Android Support V4中的SwipeRefreshLayout支持上拉加载更多

前言 原 来的Android SDK中并没有下拉刷新组件,但是这个组件确实绝大多数APP必备的一个部件。好在google在v4包中出了一个 SwipeRefreshLayout,但是这个组件只支持下拉刷新,不支持上拉加载更多的操作。因此,我们就来简单的扩展一下这个组件以实现上拉下载的 目的。 基本原理 上 拉加载或者说滚动到底部时自动加载,都是通过判断是否滚动到了ListView或者其他View的底部,然后触发相应的操作,这里我们以ListView 来说明。因此我们需要在监听ListView的滚动事件,当ListView滚动到底部时自动触发加载操作;但是当用户支持手指滑动屏幕,没有滚动时,我 们也需要让它加载,因此这种情形就是上拉加载更多。所以我们需要在触摸事件里面进行判断,如果到了底部,且用户是上拉操作,那么执行加载更多。更多关于下 拉刷新、上拉加载请参考[打造通用的Android下拉刷新组件(适用于ListView、GridView等各类View)](http://blog.csdn.net/bboyfeiyu/article/details/39718861)。 时间有限,直接上代码吧。 实现代码 **[java]** [view plain](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[copy](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/503362)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/503362/fork) <div> <embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18" height="18" align="middle" name="ZeroClipboardMovie_1"> </embed> </div> </div> </div> - <span class="comment">/**</span> - <span class="comment"> * 继承自SwipeRefreshLayout,从而实现滑动到底部时上拉加载更多的功能.</span> - <span class="comment"> * </span> - <span class="comment"> * @author mrsimple</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">class</span> RefreshLayout <span class="keyword">extends</span> SwipeRefreshLayout <span class="keyword">implements</span> OnScrollListener { - - <span class="comment">/**</span> - <span class="comment"> * 滑动到最下面时的上拉操作</span> - <span class="comment"> */</span> - - <span class="keyword">private</span> <span class="keyword">int</span> mTouchSlop; - <span class="comment">/**</span> - <span class="comment"> * listview实例</span> - <span class="comment"> */</span> - <span class="keyword">private</span> ListView mListView; - - <span class="comment">/**</span> - <span class="comment"> * 上拉监听器, 到了最底部的上拉加载操作</span> - <span class="comment"> */</span> - <span class="keyword">private</span> OnLoadListener mOnLoadListener; - - <span class="comment">/**</span> - <span class="comment"> * ListView的加载中footer</span> - <span class="comment"> */</span> - <span class="keyword">private</span> View mListViewFooter; - - <span class="comment">/**</span> - <span class="comment"> * 按下时的y坐标</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">int</span> mYDown; - <span class="comment">/**</span> - <span class="comment"> * 抬起时的y坐标, 与mYDown一起用于滑动到底部时判断是上拉还是下拉</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">int</span> mLastY; - <span class="comment">/**</span> - <span class="comment"> * 是否在加载中 ( 上拉加载更多 )</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">boolean</span> isLoading = <span class="keyword">false</span>; - - <span class="comment">/**</span> - <span class="comment"> * @param context</span> - <span class="comment"> */</span> - <span class="keyword">public</span> RefreshLayout(Context context) { - <span class="keyword">this</span>(context, <span class="keyword">null</span>); - } - - <span class="keyword">public</span> RefreshLayout(Context context, AttributeSet attrs) { - <span class="keyword">super</span>(context, attrs); - - mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); - - mListViewFooter = LayoutInflater.from(context).inflate(R.layout.listview_footer, <span class="keyword">null</span>, - <span class="keyword">false</span>); - } - - <span class="annotation">@Override</span> - <span class="keyword">protected</span> <span class="keyword">void</span> onLayout(<span class="keyword">boolean</span> changed, <span class="keyword">int</span> left, <span class="keyword">int</span> top, <span class="keyword">int</span> right, <span class="keyword">int</span> bottom) { - <span class="keyword">super</span>.onLayout(changed, left, top, right, bottom); - - <span class="comment">// 初始化ListView对象</span> - <span class="keyword">if</span> (mListView == <span class="keyword">null</span>) { - getListView(); - } - } - - <span class="comment">/**</span> - <span class="comment"> * 获取ListView对象</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">void</span> getListView() { - <span class="keyword">int</span> childs = getChildCount(); - <span class="keyword">if</span> (childs > <span class="number"></span>) { - View childView = getChildAt(<span class="number"></span>); - <span class="keyword">if</span> (childView <span class="keyword">instanceof</span> ListView) { - mListView = (ListView) childView; - <span class="comment">// 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载</span> - mListView.setOnScrollListener(<span class="keyword">this</span>); - Log.d(VIEW_LOG_TAG, <span class="string">&#8220;### 找到listview&#8221;</span>); - } - } - } - - <span class="comment">/*</span> - <span class="comment"> * (non-Javadoc)</span> - <span class="comment"> * @see android.view.ViewGroup#dispatchTouchEvent(android.view.MotionEvent)</span> - <span class="comment"> */</span> - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">boolean</span> dispatchTouchEvent(MotionEvent event) { - <span class="keyword">final</span> <span class="keyword">int</span> action = event.getAction(); - - <span class="keyword">switch</span> (action) { - <span class="keyword">case</span> MotionEvent.ACTION_DOWN: - <span class="comment">// 按下</span> - mYDown = (<span class="keyword">int</span>) event.getRawY(); - <span class="keyword">break</span>; - - <span class="keyword">case</span> MotionEvent.ACTION_MOVE: - <span class="comment">// 移动</span> - mLastY = (<span class="keyword">int</span>) event.getRawY(); - <span class="keyword">break</span>; - - <span class="keyword">case</span> MotionEvent.ACTION_UP: - <span class="comment">// 抬起</span> - <span class="keyword">if</span> (canLoad()) { - loadData(); - } - <span class="keyword">break</span>; - <span class="keyword">default</span>: - <span class="keyword">break</span>; - } - - <span class="keyword">return</span> <span class="keyword">super</span>.dispatchTouchEvent(event); - } - - <span class="comment">/**</span> - <span class="comment"> * 是否可以加载更多, 条件是到了最底部, listview不在加载中, 且为上拉操作.</span> - <span class="comment"> * </span> - <span class="comment"> * @return</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">boolean</span> canLoad() { - <span class="keyword">return</span> isBottom() && !isLoading && isPullUp(); - } - - <span class="comment">/**</span> - <span class="comment"> * 判断是否到了最底部</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">boolean</span> isBottom() { - - <span class="keyword">if</span> (mListView != <span class="keyword">null</span> && mListView.getAdapter() != <span class="keyword">null</span>) { - <span class="keyword">return</span> mListView.getLastVisiblePosition() == (mListView.getAdapter().getCount() &#8211; <span class="number">1</span>); - } - <span class="keyword">return</span> <span class="keyword">false</span>; - } - - <span class="comment">/**</span> - <span class="comment"> * 是否是上拉操作</span> - <span class="comment"> * </span> - <span class="comment"> * @return</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">boolean</span> isPullUp() { - <span class="keyword">return</span> (mYDown &#8211; mLastY) >= mTouchSlop; - } - - <span class="comment">/**</span> - <span class="comment"> * 如果到了最底部,而且是上拉操作.那么执行onLoad方法</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">void</span> loadData() { - <span class="keyword">if</span> (mOnLoadListener != <span class="keyword">null</span>) { - <span class="comment">// 设置状态</span> - setLoading(<span class="keyword">true</span>); - <span class="comment">//</span> - mOnLoadListener.onLoad(); - } - } - - <span class="comment">/**</span> - <span class="comment"> * @param loading</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">void</span> setLoading(<span class="keyword">boolean</span> loading) { - isLoading = loading; - <span class="keyword">if</span> (isLoading) { - mListView.addFooterView(mListViewFooter); - } <span class="keyword">else</span> { - mListView.removeFooterView(mListViewFooter); - mYDown = <span class="number"></span>; - mLastY = <span class="number"></span>; - } - } - - <span class="comment">/**</span> - <span class="comment"> * @param loadListener</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">void</span> setOnLoadListener(OnLoadListener loadListener) { - mOnLoadListener = loadListener; - } - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onScrollStateChanged(AbsListView view, <span class="keyword">int</span> scrollState) { - - } - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onScroll(AbsListView view, <span class="keyword">int</span> firstVisibleItem, <span class="keyword">int</span> visibleItemCount, - <span class="keyword">int</span> totalItemCount) { - <span class="comment">// 滚动时到了最底部也可以加载更多</span> - <span class="keyword">if</span> (canLoad()) { - loadData(); - } - } - - <span class="comment">/**</span> - <span class="comment"> * 加载更多的监听器</span> - <span class="comment"> * </span> - <span class="comment"> * @author mrsimple</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">interface</span> OnLoadListener { - <span class="keyword">public</span> <span class="keyword">void</span> onLoad(); - } - } listview_footer.xml: **[html]** [view plain](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[copy](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/503362)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/503362/fork) <div> <embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18" height="18" align="middle" name="ZeroClipboardMovie_2"> </embed> </div> </div> </div> - <span class="tag"><?</span><span class="tag-name">xml</span> <span class="attribute">version</span>=<span class="attribute-value">&#8220;1.0&#8221;</span> <span class="attribute">encoding</span>=<span class="attribute-value">&#8220;utf-8&#8221;</span><span class="tag">?></span> - <span class="tag"><</span><span class="tag-name">RelativeLayout</span> <span class="attribute">xmlns:android</span>=<span class="attribute-value">&#8220;http://schemas.android.com/apk/res/android&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;fill_parent&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;wrap_content&#8221;</span> - <span class="attribute">android:background</span>=<span class="attribute-value">&#8220;@color/umeng_comm_comments_bg&#8221;</span> - <span class="attribute">android:gravity</span>=<span class="attribute-value">&#8220;center&#8221;</span> - <span class="attribute">android:paddingBottom</span>=<span class="attribute-value">&#8220;8dip&#8221;</span> - <span class="attribute">android:paddingTop</span>=<span class="attribute-value">&#8220;5dip&#8221;</span> <span class="tag">></span> - - <span class="tag"><</span><span class="tag-name">ProgressBar</span> - <span class="attribute">android:id</span>=<span class="attribute-value">&#8220;@+id/pull_to_refresh_load_progress&#8221;</span> - <span class="attribute">style</span>=<span class="attribute-value">&#8220;@android:style/Widget.ProgressBar.Small.Inverse&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;wrap_content&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;wrap_content&#8221;</span> - <span class="attribute">android:layout_centerVertical</span>=<span class="attribute-value">&#8220;true&#8221;</span> - <span class="attribute">android:layout_centerHorizontal</span>=<span class="attribute-value">&#8220;true&#8221;</span> - <span class="attribute">android:paddingRight</span>=<span class="attribute-value">&#8220;100dp&#8221;</span> - <span class="attribute">android:indeterminate</span>=<span class="attribute-value">&#8220;true&#8221;</span> <span class="tag">/></span> - - <span class="tag"><</span><span class="tag-name">TextView</span> - <span class="attribute">android:id</span>=<span class="attribute-value">&#8220;@+id/pull_to_refresh_loadmore_text&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;fill_parent&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;wrap_content&#8221;</span> - <span class="attribute">android:layout_gravity</span>=<span class="attribute-value">&#8220;center&#8221;</span> - <span class="attribute">android:gravity</span>=<span class="attribute-value">&#8220;center&#8221;</span> - <span class="attribute">android:paddingTop</span>=<span class="attribute-value">&#8220;5dip&#8221;</span> - <span class="attribute">android:text</span>=<span class="attribute-value">&#8220;@string/load&#8221;</span> - <span class="attribute">android:textAppearance</span>=<span class="attribute-value">&#8220;?android:attr/textAppearanceMedium&#8221;</span> - <span class="attribute">android:textColor</span>=<span class="attribute-value">&#8220;@android:color/darker_gray&#8221;</span> - <span class="attribute">android:textSize</span>=<span class="attribute-value">&#8220;14sp&#8221;</span> - <span class="attribute">android:textStyle</span>=<span class="attribute-value">&#8220;bold&#8221;</span> <span class="tag">/></span> - - <span class="tag"></</span><span class="tag-name">RelativeLayout</span><span class="tag">></span> 使用示例 refresh.xml布局文件: **[html]** [view plain](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[copy](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/503362)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/503362/fork) <div> <embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18" height="18" align="middle" name="ZeroClipboardMovie_3"> </embed> </div> </div> </div> - <span class="tag"><?</span><span class="tag-name">xml</span> <span class="attribute">version</span>=<span class="attribute-value">&#8220;1.0&#8221;</span> <span class="attribute">encoding</span>=<span class="attribute-value">&#8220;utf-8&#8221;</span><span class="tag">?></span> - <span class="tag"><</span><span class="tag-name">myview.RefreshLayout</span> <span class="attribute">xmlns:android</span>=<span class="attribute-value">&#8220;http://schemas.android.com/apk/res/android&#8221;</span> - <span class="attribute">android:id</span>=<span class="attribute-value">&#8220;@+id/swipe_layout&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;match_parent&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;match_parent&#8221;</span> <span class="tag">></span> - - <span class="tag"><</span><span class="tag-name">ListView</span> - <span class="attribute">android:id</span>=<span class="attribute-value">&#8220;@+id/listview&#8221;</span> - <span class="attribute">android:layout_width</span>=<span class="attribute-value">&#8220;match_parent&#8221;</span> - <span class="attribute">android:layout_height</span>=<span class="attribute-value">&#8220;match_parent&#8221;</span> <span class="tag">></span> - <span class="tag"></</span><span class="tag-name">ListView</span><span class="tag">></span> - - <span class="tag"></</span><span class="tag-name">myview.RefreshLayout</span><span class="tag">></span> activity中的使用 : **[java]** [view plain](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[copy](http://blog.csdn.net/bboyfeiyu/article/details/39935329#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/503362)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/503362/fork) <div> <embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18" height="18" align="middle" name="ZeroClipboardMovie_4"> </embed> </div> </div> </div> - <span class="comment">/**</span> - <span class="comment"> * @author mrsimple</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">class</span> MainActivity <span class="keyword">extends</span> Activity { - - <span class="annotation">@Override</span> - <span class="keyword">protected</span> <span class="keyword">void</span> onCreate(Bundle savedInstanceState) { - <span class="keyword">super</span>.onCreate(savedInstanceState); - - setContentView(R.layout.refresh); - - <span class="comment">// 模拟一些数据</span> - <span class="keyword">final</span> List<String> datas = <span class="keyword">new</span> ArrayList<String>(); - <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number"></span>; i < <span class="number">20</span>; i++) { - datas.add(<span class="string">&#8220;item &#8211; &#8220;</span> + i); - } - - <span class="comment">// 构造适配器</span> - <span class="keyword">final</span> BaseAdapter adapter = <span class="keyword">new</span> ArrayAdapter<String>(<span class="keyword">this</span>, - android.R.layout.simple_list_item_1, - datas); - <span class="comment">// 获取listview实例</span> - ListView listView = (ListView) findViewById(R.id.listview); - listView.setAdapter(adapter); - - <span class="comment">// 获取RefreshLayout实例</span> - <span class="keyword">final</span> RefreshLayout myRefreshListView = (RefreshLayout) - findViewById(R.id.swipe_layout); - - <span class="comment">// 设置下拉刷新时的颜色值,颜色值需要定义在xml中</span> - myRefreshListView - .setColorScheme(R.color.umeng_comm_text_topic_light_color, - R.color.umeng_comm_yellow, R.color.umeng_comm_green, - R.color.umeng_comm_linked_text); - <span class="comment">// 设置下拉刷新监听器</span> - myRefreshListView.setOnRefreshListener(<span class="keyword">new</span> OnRefreshListener() { - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onRefresh() { - - Toast.makeText(MainActivity.<span class="keyword">this</span>, <span class="string">&#8220;refresh&#8221;</span>, Toast.LENGTH_SHORT).show(); - - myRefreshListView.postDelayed(<span class="keyword">new</span> Runnable() { - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> run() { - <span class="comment">// 更新数据</span> - datas.add(<span class="keyword">new</span> Date().toGMTString()); - adapter.notifyDataSetChanged(); - <span class="comment">// 更新完后调用该方法结束刷新</span> - myRefreshListView.setRefreshing(<span class="keyword">false</span>); - } - }, <span class="number">1000</span>); - } - }); - - <span class="comment">// 加载监听器</span> - myRefreshListView.setOnLoadListener(<span class="keyword">new</span> OnLoadListener() { - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onLoad() { - - Toast.makeText(MainActivity.<span class="keyword">this</span>, <span class="string">&#8220;load&#8221;</span>, Toast.LENGTH_SHORT).show(); - - myRefreshListView.postDelayed(<span class="keyword">new</span> Runnable() { - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> run() { - datas.add(<span class="keyword">new</span> Date().toGMTString()); - adapter.notifyDataSetChanged(); - <span class="comment">// 加载完后调用该方法</span> - myRefreshListView.setLoading(<span class="keyword">false</span>); - } - }, <span class="number">1500</span>); - - } - }); - } - - } 效果图 ![](http://img.blog.csdn.net/20141009181845718) github链接 : [下拉刷新库](https://github.com/bboyfeiyu/android_my_pull_refresh_view) 。 示例在android_my_pull_demo工程中,进入demo后点击最后一个按钮查看效果即可。注意,在刷新和加载时,需要有一定的延时才能看到效果,这里我们用postDelay来模拟网络请求等延时操作,否则将看不到加载效果。

2015年6月12日 · 7 分钟 · 天边的星星

Material Design开发利器

Android 5.0 Lollipop 是迄今为止最重大的一次发布,很大程度上是因为 material design —— 这是一门新的设计语言,它刷新了整个 Android 的用户体验。但是对于开发者来说,要设计出完全符合 material design 哲学的应用,是一个很大的挑战。Android Design Support Library 对此提供了很好的支持,里面汇集了很多重要的 material design 控件,支持所有 Android 2.1 及后续版本。里面你可以看到 navigation drawer view、floating labels、floating action button、snackbar、tabs,以及一套将它们紧密结合在一起的动作与滚动框架。 Navigation View(导航视图) 无论从应用标识、内容导航,还是设计一致性来讲,navigation drawer 都是首当其冲的焦点。现在,NavigationView 让导航栏变得更简单,它提供了 navigation drawer 需要的框架,以及通过资源文件来自定义更多菜单项的能力。 ![navigationview](http://ac-lhzo7z96.clouddn.com/1433285108918) 你只需要将 NavigationView 作为 DrawerLayout 的内容视图来使用即可,例如: ![drawerlayout](http://ac-lhzo7z96.clouddn.com/1433297055793) 这里你会注意到两个属性:app:heanderLaytout 用来控制 header 部分的布局;app:menu 指定了菜单资源。NavigationView 自动处理了状态栏的变化,保证可以在 API 21+ 的设备上正确运行。 最简单的 drawer 菜单就是一个允许选择的菜单项集合,例如: ![simplemenu](http://ac-lhzo7z96.clouddn.com/1433297095098) 选中的菜单会高亮显示,以提醒用户当前选择的是哪个菜单项。 你也可以在菜单中使用 subheader 来实现独立的分组: ![subheader_menu](http://ac-lhzo7z96.clouddn.com/1433297134486) 调用 setNavigationItemSelectedListener() 后,在菜单项被选中的时候,你会通过OnNavigationItemSelectedListener 得到回调。在处理回调时,你会知道是哪个菜单项被点击,此时你可以处理选择事件,修改选中状态,加载新的内容,以及通过代码来关闭 drawer,或者其他任何你想执行的操作。 文字输入时的悬浮标签 尽管 EditText 已经为 material design 做了一些改善,但是还不够,譬如它在我们输入第一个字符的时候,就会自动隐藏掉提示标签。现在你该使用 TextInputLayout 了,它会在用户开始输入之后,自动将提示标签悬浮到 EditText 上方,这样用户就永远都能知道输入内容的上下文。 ...

2015年6月6日 · 2 分钟 · 天边的星星

用户手势检测-GestureDetector使用详解

一、概述 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing等等。 一般情况下,我们知道View类有个View.OnTouchListener内部接口,通过重写他的onTouch(View v, MotionEvent event)方法,我们可以处理一些touch事件,但是这个方法太过简单,如果需要处理一些复杂的手势,用这个接口就会很麻烦(因为我们要自己根据用户触摸的轨迹去判断是什么手势)。 Android sdk给我们提供了GestureDetector(Gesture:手势Detector:识别)类,通过这个类我们可以识别很多的手势,主要是通过他的onTouchEvent(event)方法完成了不同手势的识别。虽然他能识别手势,但是不同的手势要怎么处理,应该是提供给程序员实现的。 GestureDetector这个类对外提供了两个接口和一个外部类 接口:OnGestureListener,OnDoubleTapListener 内部类:SimpleOnGestureListener 这个外部类,其实是两个接口中所有函数的集成,它包含了这两个接口里所有必须要实现的函数而且都已经重写,但所有方法体都是空的;不同点在于:该类是static class,程序员可以在外部继承这个类,重写里面的手势处理方法。 下面我们先看OnGestureListener接口; 二、GestureDetector.OnGestureListener—接口 1、基本讲解 如果我们写一个类并implements OnGestureListener,会提示有几个必须重写的函数,加上之后是这个样子的: **[java]** [view plain](http://blog.csdn.net/harvic880925/article/details/39520901#)[copy](http://blog.csdn.net/harvic880925/article/details/39520901#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/475851)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/475851/fork) <div> <embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash" width="18" height="18" align="middle" name="ZeroClipboardMovie_1"> </embed> </div> </div> - <span class="keyword">private</span> <span class="keyword">class</span> gesturelistener <span class="keyword">implements</span> GestureDetector.OnGestureListener{ - - <span class="keyword">public</span> <span class="keyword">boolean</span> onDown(MotionEvent e) { - <span class="comment">// TODO Auto-generated method stub</span> - <span class="keyword">return</span> <span class="keyword">false</span>; - } - - <span class="keyword">public</span> <span class="keyword">void</span> onShowPress(MotionEvent e) { - <span class="comment">// TODO Auto-generated method stub</span> - - } - - <span class="keyword">public</span> <span class="keyword">boolean</span> onSingleTapUp(MotionEvent e) { - <span class="comment">// TODO Auto-generated method stub</span> - <span class="keyword">return</span> <span class="keyword">false</span>; - } - - <span class="keyword">public</span> <span class="keyword">boolean</span> onScroll(MotionEvent e1, MotionEvent e2, - <span class="keyword">float</span> distanceX, <span class="keyword">float</span> distanceY) { - <span class="comment">// TODO Auto-generated method stub</span> - <span class="keyword">return</span> <span class="keyword">false</span>; - } - - <span class="keyword">public</span> <span class="keyword">void</span> onLongPress(MotionEvent e) { - <span class="comment">// TODO Auto-generated method stub</span> - - } - - <span class="keyword">public</span> <span class="keyword">boolean</span> onFling(MotionEvent e1, MotionEvent e2, <span class="keyword">float</span> velocityX, - <span class="keyword">float</span> velocityY) { - <span class="comment">// TODO Auto-generated method stub</span> - <span class="keyword">return</span> <span class="keyword">false</span>; - } - - } 可见,这里总共重写了六个函数,这些函数都在什么情况下才会触发呢,下面讲一下: ...

2015年4月28日 · 11 分钟 · 天边的星星

ym——Android仿QQ5.0侧滑菜单ResideMenu源码分析

AndroidResideMenu ![](http://www.2cto.com/uploadfile/Collfiles/20140911/20140911091421122.gif) 先看看如何使用: 把项目源码下载下来导入工程,可以看到 ![](http://www.2cto.com/uploadfile/Collfiles/20140911/20140911091422123.jpg) ResideMenu为引用工程,再看看如何使用这个引用工程来构建出ResideMenu, 1.先new一个ResideMenu对象 [?](http://www.2cto.com/kf/201409/332224.html#) <table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="gutter"> <div class="line number1 index0 alt2"> 1 </div> </td> <td class="code"> <div class="container"> <div class="line number1 index0 alt2"> `resideMenu = ``new` `ResideMenu(``this``);` </div> </div> </td> </tr> </table> 2.设置它的背景图片 [?](http://www.2cto.com/kf/201409/332224.html#) <table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="gutter"> <div class="line number1 index0 alt2"> 1 </div> </td> <td class="code"> <div class="container"> <div class="line number1 index0 alt2"> `resideMenu.setBackground(R.drawable.menu_background);` </div> </div> </td> </tr> </table> 3.绑定当前Activity ...

2015年3月3日 · 36 分钟 · 天边的星星