在Centos7上使用YUM升级更新Git版本(Git 2.x )

网站在部署到服务器的这个过程,有时候会非常麻烦,以前SEO禅都是用FTP或者用rsync命令,现在因为Github私有仓库免费了,就直接使用Git来部署,修改后的源码只要Push到仓库里,再在服务器Pull下来,别说有多方便有多爽了,要是再使用Docker去部署服务器程序,那就是分分种搞定网站部署的事,以前要部署一个网站少说要个把小时,这篇文章主要是分享下在阿里云的ECS服务器如何更新Git到2.x版本。 更新方法 默认在Centos上使用YUM命令安装的Git版本是1.8x,在使用的时候会有些问题,有很多种更新办法,这里只分享最简单方便的一种,先运行如下命令看看Git的版本信息: `git --version git version 1.8.3.1 ` 如果这不是你想要的版本,那我们第一步要做的就是先移除Git,运行如下命令: `sudo yum remove git* ` 之后安装相关的RPM仓库,运行如下命令: `sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm ` 再重新安装一遍Git,运行如下命令: `sudo yum install git ` 当出现提示的时候,输入y,完成安装 再看看安装后的Git版本: `git --version `

2021年10月9日 · 1 分钟 · 天边的星星

Gitea 安装配置及使用

Gitea 安装配置 在很多时候,我们希望有自己的git仓库管理,把我们隐私的一点点工程,放在里面。大家也可以去使用目前网上免费的,例如 github、gitee 、gitlab、 coding.net、gogs、gitea等 Centos 安装Gitea 下载gitea wget -O gitea https://dl.gitea.io/gitea/1.12.1/gitea-1.12.1-linux-amd64 下载下来的gitea是没有 执行权限的,我们需要给他执行权限 chmod a+x gitea 复制gitea到 /usr/log/bin 方便我们之间执行 cp gitea /usr/local/bin/ 执行 启动 gitea web 根据gitea 页面信息,进行初始化配置,配置最后所在文件地址 cat /usr/local/bin/custom/conf/app.ini 如果需要后台运行 使用 nohup gitea >/dev/null 2>&1 & 命令 完成 开心的使用Gitea吧 通过 ps -ef |grep gitea |grep -v “grep”|wc -l 查询是否运行 返回1 表示运行 通过 ps -ef |grep gitea |grep -v “grep” 查询具体的执行信息

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

Android 中gitWindow可以做的事情

View view = getWindow().getDecorView().findViewById(R.id.activity_main); if (view == null) return; ViewParent viewParent = view.getParent(); if (viewParent instanceof FrameLayout) { final FrameLayout frameParent = (FrameLayout) viewParent;//整个父布局 final LinearLayout linearLayout = new LinearLayout(this);//新建一个LinearLayout linearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setBackgroundResource(#88000000);//背景设置灰色透明 linearLayout.setGravity(Gravity.CENTER_HORIZONTAL); linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { frameParent.removeView(linearLayout); } }); Rect rect = new Rect(); Point point = new Point(); nearby.getGlobalVisibleRect(rect, point);//获得nearby这个控件的宽高以及XY坐标 nearby这个控件对应就是需要高亮显示的地方 ImageView topGuideview = new ImageView(this); topGuideview.setLayoutParams(new ViewGroup.LayoutParams(rect.width(), rect.height())); topGuideview.setBackgroundResource(R.drawable.iv_topguide); ...

2017年2月20日 · 1 分钟 · 天边的星星

AS中Git与GitHub的使用入门

一直想把自己的写的开源小项目放到github中,这两天才花时间来学学Git。遇到些问题,百度了很多才解决。跟SVN一样,值得写一篇总结记录下,虽然上资源很多,但作为入门,自己遇到的写出来完全不一样。 一、 Git与GitHub的简单介绍 Git是一个开源的分布式版本控制工具。 GitHub是一个使用Git作为版本控制的项目托管平台,它是一个网站。 详细请参考:http://www.cnblogs.com/cocowool/archive/2012/02/17/2356125.html 二、 Git的安装 下载地址:https://git-scm.com/download/win 或 https://git-for-windows.github.io/ 安装时,全部默认选择即可。 三、 AS中配置Git与GitHub 1. Git的配置 在Settings设置中。 Path to Git executable: 【Git安装后的路径】 然后“Test”测试一下,成功才可以。 2. GitHub的配置 Host: github.com Login: 【你的github用户名】 Password: 【github登录密码】 填好后,也进行“Test”测试一下,同样成功才可以。 测试完后按确定,会提示你是否设置密码,看个人需求。 四、 上传代码到GitHub 1. 创建GitHub仓库 在Github上创建一个仓库: 创建好后,将是这个样子,里面包括一个.gitignore忽略配置文件和一个README.md git地址如下: 2. 创建Git本地仓库 选择工程 —— VCS —— …… 此时,VCS的5个图标显示出来了,且要提交的文件名都是暗红色 3. 把工程add添加到仓库 选择工程 —— 右键 —— Git —— Add Add后待提交的文件名是绿色 4. commit提交 CommitMessage:填入提交说明信息。主要用于说明你做了哪些修改。 按Commit提交即可。 注:我每次都无法提交,commit后,进度对话框走到一半就立马消失了。解决办法见下面常见问题的“无法commit”。 提交后的文件颜色是灰白色。修改过的文件时淡蓝色 5. push推送到GitHub Commit后会自动弹出Push推送窗口,点“Define remote”。 Name:默认origin URL:就是github的网页地址,上面已提供获取方法 ...

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

用 Google Cloud 打造你的私有免费 Git 仓库

作为开发者平时可能想写点(非开源)的小东西,或者想保存一些私人配置什么的,这些也应该以 Git 的形式长期保存。毕竟 Git 的用途很广,有一份云端备份也很明智。但 Github 等服务只对开源项目免费,私有项目是按月收费的,并且还有仓库数量限制。自己的一些小作品或个人记录一般没有多大商业价值,项目本身又非常小,所以不值得花钱购买 Git 服务,但又不太适合公开。这种情况下你就需要一些可靠的免费私有 Git 仓库了。 其实,Google 云平台上有一个 Cloud Source Repositories 服务,这就是我们需要的私有 Git 仓库功能。这个服务本意是让你的项目方便地在 Google Cloud 上集成和调试,但是你也可以只使用这个服务,当成你的免费私有仓库。以前 Google Cloud 中一个项目只能有一个仓库,用起来不方便,现在一个项目中可以建任意多个私有仓库了。Cloud Source Repositories beta 版服务是完全免费的,存储上限是 1 G ,一般存储源码等文本文件是足够用的。 除了私有、免费之外,Cloud Source Repositories 还有以下优点: 作为 Google 的服务,存储绝对安全、可靠。 一个 Cloud 项目下可以创建任意多个仓库。 支持代码编辑器,可以用浏览器在线查看、编辑、提交和仓库管理。 可以多人协作,访问私有仓库。 支持 GitHub 和 Bitbucket 仓库同步。 与 Google Cloud 的其它服务无缝集成。 使用方法和标准 Git 没有不同,唯一的差异是初始的账号认证方式不同。假设你已经本地安装了 Git ,然后你需要安装 Google Cloud SDK (一个命令行工具) 来初始化项目和账号认证,仅第一次需要。当然,你还需要在 Google Cloud 上新建一个项目作为服务的归属,并设置你的收费方式(不使用其他收费服务的话不用担心扣费)。具体 Git 服务的使用 Google 官方文档已经写地非常细致了,控制台上也一目了然(Git 服务是控制台菜单中的 Development)。 ...

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

GitHub 上排名前 100 的 Android 开源库简介

本项目主要对目前 GitHub 上排名前 100 的 Android 开源库进行简单的介绍, 至于排名完全是根据GitHub搜索Java语言选择 (Best Match) 得到的结果, 然后过滤了跟Android不相关的项目, 所以排名并不具备任何官方效力, 仅供参考学习, 方便初学者快速了解当前一些流行的Android开源库. iOS 版本的在此: https://github.com/Aufree/trip-to-iOS/blob/master/Top-100.md 感谢 @GitHubDaily 的大力支持, 以及 @stormzhang 的指点 若有任何疑问可通过邮件或微博联系我 项目名称 <th> 项目简介 </th> 1. [react-native](https://github.com/facebook/react-native) <td width="275"> 这个是 Facebook 在 React.js Conf 2015 大会上推出的基于 JavaScript 的开源框架 React Native, 该框架结合了 Web 应用和 Native 应用的优势, 可以使用 JavaScript 来开发 iOS 和 Android 原生应用 </td> 2.[Android-Universal-Image-Loader](https://github.com/nostra13/Android-Universal-Image-Loader) <td width="275"> ImageLoader 是最早开源的 Android 图片缓存库, 强大的缓存机制, 早期被广泛 Android 应用使用, 至今仍然有很多 Android 开发者在使用 </td> 3. [RxJava](https://github.com/ReactiveX/RxJava) <td width="275"> RxJava 是一个在 Java VM 上使用可观测的序列来组成异步的、基于事件的程序的库, 简单来说它就是一个实现异步操作的库, RxJava 的优点在于一个词 &#8220;简洁&#8221;, 使用它就算你程序逻辑有多么复杂, 它依然能够保持简洁易懂 </td> 4. [retrofit](https://github.com/square/retrofit) <td width="275"> Retrofit 是 Square 公司出品的 HTTP 请求库, 同时是 Square 是最早开源项目之一, Retrofit 是目前 Android 最流行的 Http Client 库之一, 目前版本是 Retrofit2.0 Beta4, 越来越多 Android 开发者开始使用这个请求库了 </td> 5. [okhttp](https://github.com/square/okhttp) <td width="275"> OkHttp 是 Square 公司出品的 HTTP 另一个请求库, Google 不推荐人们使用 HttpClient, 可是 HttpURLConnection 实在是太难用了, 因此很多人使用了 OkHttp 来解决这问题, 据说 Android4.4 的源码中可以看到 HttpURLConnection 已经替换成 OkHttp 实现呢 </td> 6. [SlidingMenu(不建议使用)](https://github.com/jfeinstein10/SlidingMenu) <td width="275"> 一个侧滑菜单开源库, 在 Google 自己原生态的侧滑菜单 NavigationDrawer 没有出现之前, 这个库就已经被广泛使用, 可是到现在这个库已经被放弃了 </td> 7. [picasso](https://github.com/square/picasso) <td width="275"> Picasso 是 Square 公司出品的一款图片缓存库, 主导者是 JakeWharton 大神 </td> 8. [android-best-practices](https://github.com/futurice/android-best-practices) <td width="275"> Android 开发最佳实践, 里面所介绍的经验都是来自于 Futurice 公司 Android 开发者, 介绍内容有 Android 开发规范、架构、布局技巧, 以及使用一些有助于快速开发相关工具等等, 非常适合新手去学习 </td> 9. [EventBus](https://github.com/greenrobot/EventBus) <td width="275"> EventBus 是 Android 事件管理总线, 使用它可以替带 Android BroadCast, BroadCastReceiver, Handler 在 Activity, Fragment, Service, 线程之间传递消息, 大大简化了事件传递逻辑 </td> 10. [android-async-http](https://github.com/loopj/android-async-http) <td width="275"> Android-Async-Http 是 Android 一款老牌异步请求库, 专门对 Android 在 Apache 的 HttpClient 基础上构建的异步 http 连接, 该库有很多特征, 例如: 库的 size 小, 支持文件上传不需使用第三方库支持, 内部使用线程池来处理并发, 等等 </td> 11. [fresco](https://github.com/facebook/fresco) <td width="275"> Fresco 是 FaceBook 公司出品的一款图片缓存库, Fresco 是一个强大的图片加载组件, 支持加载 Gif 图和 WebP 格式, 支持 Android2.3(API level 9) 及其以上系统, Fresco 中设计了 Image pipeline 和 Drawees 两个模块各施其职, 使得图片完美加载出来, 想知道更多 image pipeline 和 Drawees 有关于它的特性, 可以到它[官方平台](http://fresco-cn.org/)看介绍 </td> 12. [zxing](https://github.com/zxing/zxing) <td width="275"> ZXing 是二维码领域中名气最大的开源项目, 它提供了多个平台的二维码/条形码扫描解决方案, 拥有扫描快, 识别率高, 使用简单等特点 </td> 13. [leakcanary](https://github.com/square/leakcanary) <td width="275"> LeakCanary 是 Square 公司出的一款检测内存泄露工具, 该工具能帮助你在开发阶段方便的检测出内存泄露的问题, 使用起来非常简单方便 </td> 14. [butterknife](https://github.com/JakeWharton/butterknife) <td width="275"> 由 JakeWharton 大神开发出来的, ButterKnife 是 View 注入框架, 使用它为了简写很多 findViewById 代码, 同时还支持 View 的一些事件处理函数 </td> 15. [MPAndroidChart](https://github.com/PhilJay/MPAndroidChart) <td width="275"> MPAndroidChart 是一款强大的 Android 图表库, 支持各种各样图表显示, 能想到的图表样式这里几乎都有, 图表还支持选择, 拖放和缩放动画效果 </td> 16.[ActionBarSherlock(不建议使用)](https://github.com/JakeWharton/ActionBarSherlock) <td width="275"> ActionBarSherlock 这个库是 JakeWharton 大神开发出来支持 Android3.0 以下版本的, 后来慢慢的 Google 也提供了 AppCompat 库来支持 Android3.0 以下版本使用 ActionBar, 因此作者不建议我们再使用这个库了 </td> 17. [androidannotations](https://github.com/excilys/androidannotations) <td width="275"> AndroidAnnotations 是一个能够让你快速进行 Android 开发的开源框架, 它能让你专注于真正重要的地方, 使代码更加精简, 使项目更加容易维护, 它的目标就是 &#8220;Fast Android Development.Easy maintainance&#8221; </td> 18. [ViewPagerIndicator](https://github.com/JakeWharton/ViewPagerIndicator) <td width="275"> 由 JakeWharton 大神开发出来的一个 ViewPager 指示器, 使用起来简单方便, 可高度定制, 开发出各种各样动画效果 </td> 19. [glide](https://github.com/bumptech/glide) <td width="275"> Glide 是 Google 员工的开源项目, 广泛应用于 Google 一些 App 上, 在2014年 Google I/O 大会上被推荐使用, Glide 和 Picasso 被人拿来比较研究过, Glide 与 Picasso 有 90% 的相似度, 但在一些细节上还是有点区别的, 各有各优缺点看君选择 </td> 20. [HomeMirror](https://github.com/HannahMitt/HomeMirror) <td width="275"> 开发者是由一名程序媛 Hannah Mittelstaedt , HomeMirror 是一款 Android 镜子应用, 目前它能实现日期, 时间, 天气, 生日信息, 事件提醒器, 骑车天气的推荐, 股票信息, XKCD 漫画网站的新帖等等 </td> 21. [Android-PullToRefresh(不建议使用)](https://github.com/chrisbanes/Android-PullToRefresh) <td width="275"> 一个强大的拉动刷新开源项目,支持各种控件下拉刷新,ListView、ViewPager、WebView、ExpandableListView、GridView、ScrollView、Horizontal ScrollView、Fragment 上下左右拉动刷新, 不过现在这个项目已经停止维护更新了, 推荐使用 Android-Ultra-Pull-to-Refresh </td> 22. [MaterialDesignLibrary](https://github.com/navasmdc/MaterialDesignLibrary) <td width="275"> 这个库控件都是遵循了 Google Material Design 设计规范开发出来, 例如有: Flat Button, Rectangle Button, CheckBox, Switch, Progress bar circular indeterminate 等等 </td> 23. [PhotoView](https://github.com/chrisbanes/PhotoView) <td width="275"> PhotoView 是 ImageView 的子类, 支持所有 ImageView 的源生行为, 例如: 支持 Pinch 手势自由缩放, 支持双击放大/还原, 支持平滑滚动等等, 并且非常方便的与 ImageLoader/Picasso 之类的网络图片读取库集成使用, 还方便的与 ViewPager 等同样支持滑动手势的控件集成 </td> 24. [RxAndroid](https://github.com/ReactiveX/RxAndroid) <td width="275"> 由 JakeWharton 大神主导开发的项目, RxAndroid 是 RxJava 的一个针对 Android 平台的扩展, 主要用于 Android 开发 </td> 25. [material-dialogs](https://github.com/afollestad/material-dialogs) <td width="275"> Material Dialogs 是一个可高度定制易用, 符合 Material Design 风格的 Dialogs, 兼容 Android API8 以上版本, 个人使用感觉它完全可替代 Android 原生那个, 比原生那个更加简单易用 </td> 26.[Android-ObservableScrollView](https://github.com/ksoichiro/Android-ObservableScrollView) <td width="275"> ObservableScrollView 是一款用于在滚动视图中观测滚动事件的 Android 库, 它能够轻而易举地与 Android 5.0 Lollipop 引进的工具栏 (Toolbar) 进行交互, 还可以帮助开发者实现拥有 Material Design 应用视觉体验的界面外观, 支持ListView, ScrollView, WebView, RecyclerView, GridView组件 </td> 27. [Android-Bootstrap](https://github.com/Bearded-Hen/Android-Bootstrap) <td width="275"> Android 版的 Bootstrap, 利用这个库能够实现很多 Bootstrap 样式风格, 之前有学过 Html 的人就知道 Bootstrap 是什么玩意啦 </td> 28. [AndroidSwipeLayout](https://github.com/daimajia/AndroidSwipeLayout) <td width="275"> 开发者是代码家, AndroidSwipeLayout 是一个支持ListView, GridView, ViewGroup等等左右上下滑动出操作菜单, 类似 qq 消息列表向左滑动显示出多某条信息的操作菜单 </td> 29. [dagger](https://github.com/square/dagger) <td width="275"> Dagger 是 Square 公司出品的一个针对 Android 和 Java 的快速依赖注入器, 能够有效减少你敲代码量 </td> 30. [ListViewAnimations](https://github.com/nhaarman/ListViewAnimations) <td width="275"> 一个轻轻松松给 Android ListView 添加动画效果的库, 支持的动画有: Alpha, SwingRightIn, SwingLeftIn, SwingBottomIn, SwingRightIn and ScaleIn等等, 使用它能很容易就实现帅爆的效果 </td> 31. [PagerSlidingTabStrip](https://github.com/astuetz/PagerSlidingTabStrip) <td width="275"> PagerSlidingTabStrip 是一个给 Android ViewPager添加上 ViewPager 滑动指示器, 从 GitHub 上面看, 这个库似乎没有人在维护了, 请谨慎使用该库 </td> 32. [AndroidViewAnimations](https://github.com/daimajia/AndroidViewAnimations) <td width="275"> 开发者是代码家, 这个库实现很多很酷炫的 Android 动画, 动画效果是借鉴 Animate.css 来实现的, 非常酷, 而且这个使用起来也是非常简单 </td> 33. [AndroidSlidingUpPanel](https://github.com/umano/AndroidSlidingUpPanel) <td width="275"> AndroidSlidingUpPanel 是一个上拉面板, 就是向上滑动的时候往上飞出一个显示面板控件, 该库效果在 Google Music, Google Maps and Rdio等 App 应用到 </td> 34. [MaterialDrawer](https://github.com/mikepenz/MaterialDrawer) <td width="275"> MaterialDrawer 是一个类似 Google 官方 NavigationView 侧滑显示控件, 个人认为 NavigationView 并没有 MaterialDrawer 实用, 因为 NavigationView 自由度不是很好, 很多都写死了不可以自由定义布局, 而 MaterialDrawer 能够实现跟 NavigationView 一样的效果, 同时还支持自定义效果, 自由度非常高 </td> 35. [Material-Animations](https://github.com/lgvalle/Material-Animations) <td width="275"> Material-Animations 是一个很好过渡动画库, 可以应用于 Activity 与 Activity 之间的跳转, Fragment 与 Fragment 之间的跳转, 以及各个 View 变化前后的过渡动画 </td> 36. [MaterialViewPager](https://github.com/florent37/MaterialViewPager) <td width="275"> 一个简单易用 Material Design 风格的 ViewPager 库 </td> 37. [ion](https://github.com/koush/ion) <td width="275"> ion 是一个让 Android 的网络操作变得极其简单, 支持异步获取和处理JSON, 支持 Android 文件下载 (同时支持下载进度条绑定), 支持安全链接和代理 </td> 38. [stetho](https://github.com/facebook/stetho) <td width="275"> Stetho是 Facebook 出品的一个强大的 Android 调试工具,使用该工具你可以在 Chrome Developer Tools查看App的布局, 网络请求(仅限使用Volley, okhttp的网络请求库), sqlite, preference, 一切都是可视化的操作,无须自己在去使用adb, 也不需要root你的设备 </td> 39. [fastjson](https://github.com/alibaba/fastjson) <td width="275"> Fastjson是一个Java语言编写的高性能功能完善的JSON库。它采用一种“假定有序快速匹配”的算法,把JSON Parse的性能提升到极致,是目前Java语言中最快的JSON库。Fastjson接口简单易用,已经被广泛使用在缓存序列化、协议交互、Web输出、Android客户端等多种应用场景 </td> 40. [cardslib](https://github.com/gabrielemariotti/cardslib) <td width="275"> Cardslib 是早期由 Gabriele Mariotti 开发的一个为开发者方便实现各种 Card UI 的 Android 开源代码库, 后来 Google 官方提供自己封装了 CardView 在 v7 包下, 使用 Google 官方的可以完全替代了这个库, 因此这个也被弃用了 </td> 41. [Android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh) <td width="275"> 开发者是廖祜秋, 这个是一个非常强大的下拉刷新库, 继承 ViewGroup 可以包含任何 View, 功能甚至比 SwipeRefreshLayout 强大, 使用起来也非常容易, 还可以自由定制自己的 UI 样式 </td> 42. [greenDAO](https://github.com/greenrobot/greenDAO) <td width="275"> greenDAO 是一个可以帮助 Android 开发者快速将 Java 对象映射到 SQLite 数据库的表单中的 ORM解决方案, 通过使用一个简单的面向对象 API, 开发者可以对 Java 对象进行存储, 更新, 删除和查询, greenDAO 相对 OrmLite, AndrORM 这两个 ORM 开源库, 性能是最高的 </td> 43. [AndroidStaggeredGrid](https://github.com/etsy/AndroidStaggeredGrid) <td width="275"> AndroidStaggeredGrid 是一个支持多列并且每一行的 item 大小不一, 交错排列的 GridView, 就是实现瀑布流样式效果, 目前该库已经被弃用了, 开发者建议我们使用 Google 官方控件 RecyleView 中的 StaggeredGridLayoutManager 布局来实现瀑布流效果 </td> 44. [otto](https://github.com/square/otto) <td width="275"> Otto 是 Square 公司出的一个事件库 (pub/sub 模式), 用来简化应用程序组件之间的通讯, otto 修改自 Google 的 Guava 库, 专门为 Android 平台进行了优化, 与上面介绍的 EventBus 相比, 两个库各有各的优点, 完全取决于我们自己项目的需求来选择它们哪一个 </td> 45. [xUtils](https://github.com/wyouflf/xUtils) <td width="275"> xUtils 是一个快速开发框架, 里面包含 DbUtils, ViewUtils, HttpUtils, BitmapUtils 四大模块, 可用于快速开发, 支持大文件上传, 拥有更加灵活的 ORM, 最低兼容 Android 2.2 </td> 46. [realm-java](https://github.com/realm/realm-java) <td width="275"> Realm 一个轻量的 Android 版本的数据存储库, 比 Android 原生系统的 SQLite 更加简洁快速对数据进行操作 </td> 47.[Android-CleanArchitecture](https://github.com/android10/Android-CleanArchitecture) <td width="275"> CleanArchitecture 是一个非常典型使用 MVP 架构的项目, 大家如果还没有理解 MVP 架构的可以看看这个项目 </td> 48. [StickyListHeaders](https://github.com/emilsjolander/StickyListHeaders) <td width="275"> StickyListHeaders 是一个实现能够固定在屏幕顶部的ListView Section Header库, 就是当前 section 的 header 固定在屏幕顶部, 当滑动到其他 section 时, 其他 section 的 header 会代替之前的 section 的 header, 固定到屏幕顶部, 类似于 Android4.0 的手机通讯录的效果 </td> 49. [AppIntro](https://github.com/PaoloRotolo/AppIntro) <td width="275"> AppIntro 是一个让人轻松快速搭建漂亮酷炫的引导页库 </td> 50. [ActiveAndroid](https://github.com/pardom/ActiveAndroid) <td width="275"> ActiveAndroid 是采用Rails中的 [Active Record](http://en.wikipedia.org/wiki/Object-relational_mapping)架构模式设计的适用于 Android 平台的轻量级 ORM 架构, 几乎可以不用写任何 SQL 代码实现快速开发 </td> 51. [android-volley](https://github.com/mcxiaoke/android-volley) <td width="275"> Volley 是谷歌官方开发团队在 2013 年 Google I/O 大会推出的一个新的网络通信框架, 这个框架把 AsyncHttpClient 和 Universal-Image-Loader 的优点集于了一身,既可以像AsyncHttpClient 一样非常简单地进行 HTTP 通信,也可以像 Universal-Image-Loader 一样轻松加载网络上的图片, 这个库并不是官方的, 只是托管同步在 Maven, 官方只提供的 Jar 包 </td> 52. [twoway-view](https://github.com/lucasr/twoway-view) <td width="275"> TwoWayView 是简化 RecyclerView 开发的一个库, 可以在其 Base LayoutManager 基础上构建各种各样的布局, 该库内置了几个常用布局 List, Grid, Staggered Grid,Spannable Grid </td> 53. [ShowcaseView](https://github.com/amlcurran/ShowcaseView) <td width="275"> ShowcaseView 是一个非常适合用于对用户进行第一次使用进行指导的库,使用起来非常简单还可以自定义样式 </td> 54. [Calligraphy](https://github.com/chrisjenx/Calligraphy) <td width="275"> Calligraphy 是一个用来简化 Android 应用使用自定义字体的类库, 该类库会自动查找应用中的 TextView 并设置其使用的字体 </td> 55. [NineOldAndroids](https://github.com/JakeWharton/NineOldAndroids) <td width="275"> NineOldAndroids 由 JakeWharton 大神开发的一个向下兼容的动画库, 主要是使低于API 11的系统也能够使用 View 的属性动画, 不过现在 JakeWharton 大神已经不推荐使用该库, 而是推荐我们使用官方封装在 Support 库里面的动画 </td> 56. [android-floating-action-button](https://github.com/futuresimple/android-floating-action-button) <td width="275"> FloatingActionButton 是一个悬浮操作按钮, 官方在 Support Design 包下也有封装一个类似这个库效果的 FloatingActionButton, 值得说明的是这个库是早在官方封装之前就存在的, 个人感觉这个库比官方那个更加好用 </td> 57. [CircleImageView](https://github.com/hdodenhof/CircleImageView) <td width="275"> CircleImageView 是一个轻松帮你实现圆形效果 ImageView 图片库, CircleImageView 是基于 ImageView 扩展出来, 因此它拥有 ImageView 控件所有属性, 简单易用值得你使用的库 </td> 58. [material](https://github.com/rey5137/material) <td width="275"> Material 是将 Material Design 风格控件封装在该库当中, 目前封装有Progress, Button, Switch, Slider, Spinner, Text Field, TabPageIndicator, SnackBar, Dialog, BottomSheetDialog, Dynamic theme </td> 59. [ActionBar-PullToRefresh](https://github.com/chrisbanes/ActionBar-PullToRefresh) <td width="275"> ActionBar-PullToRefresh 是一个下拉刷新, 下拉刷新时在 ActionBar 出现加载中提示的库 </td> 60. [FloatingActionButton](https://github.com/makovkastar/FloatingActionButton) <td width="275"> 又一个悬浮操作按钮库, 该库添加支持监听滑滚动事件, 当向下滑时按钮隐藏, 向上滑时按钮显示, 还有动画效果, 支持监听 ListView, ScrollView, RecylerView </td> 61. [AndroidAsync](https://github.com/koush/AndroidAsync) <td width="275"> AndroidAsync 是一款基于 NIO 的低端 Android 异步 socket, http (client+server), websocket 和 socket.io 网络通信协议类库 </td> 62. [rebound](https://github.com/facebook/rebound) <td width="275"> Rebound 是 Facebook 推出的一个弹性动画库, 可以让动画看起来真实自然, 像真实世界的物理运动, 带有力的效果, 使用的参数则是 Facebook 的 origami 中使用的 </td> 63. [android-common](https://github.com/Trinea/android-common) <td width="275"> android-common-lib 是 Trinea 大神收集的一些开发通用的缓存, 公共 View 以及一些常用工具类 </td> 64. [RippleEffect](https://github.com/traex/RippleEffect) <td width="275"> RippleEffect 是一个实现在 Android 任何组件点击出现 Material Design 的波纹效果, 向下兼容到 Android API9 </td> 65. [SmoothProgressBar](https://github.com/castorflex/SmoothProgressBar) <td width="275"> SmoothProgressBar 是一个帮你的 App 方便实现可定制, 平滑动画的水平滚动进度条库 </td> 66. [recyclerview-animators](https://github.com/wasabeef/recyclerview-animators) <td width="275"> RecyclerView Animators 是一个对 Recycler 控件的 Item 添加以及删除增加动画效果, 动画效果有Scale, Fade, Flip, Slide 里面各种各样效果 </td> 67. [circular-progress-button](https://github.com/dmytrodanylyk/circular-progress-button) <td width="275"> 一个带进度显示的 Button, 效果和动画做的都非常赞 </td> 68. [DroidPlugin](https://github.com/Qihoo360/DroidPlugin) <td width="275"> DroidPlugin 是 360 手机助手在 Android 系统上实现了一种新的插件机制: 它可以在无需安装, 修改的情况下运行APK文件, 此机制对改进大型APP的架构, 实现多团队协作开发具有一定的好处 </td> 69. [dynamic-load-apk](https://github.com/singwhatiwanna/dynamic-load-apk) <td width="275"> 开发者是singwhatiwanna(任玉刚), 是《Android 开发艺术探索》书籍的作者, 这个是作者联合另两位开发者啸(时之沙)和宋思宇花了几个月时间研究出来的 Apk 动态加载框架, 想了解更多关于这框架可到作者博客看 [这篇文章](http://blog.csdn.net/singwhatiwanna/article/details/39937639) 有详细介绍 </td> 70. [ExoPlayer](https://github.com/google/ExoPlayer) <td width="275"> ExoPlayer 是Google 开发团队开源出来的一个媒体播放库, 比 Android 框架原生的 MediaPlayer 拥有更多优点支持动态的自适应流 HTTP(DASH) 和 平滑流, 支持高级的HLS特性, 支持自定义和扩治你的使用场景等等 </td> 71. [Crouton](https://github.com/keyboardsurfer/Crouton) <td width="275"> Crouton 是一个显示提示信息的显示工具类, 可以用来代替Toast, 默认显示在窗口的顶部, 可以按队列一个接着一个显示, 不过该库已经被弃用, 不推荐使用 </td> 72. [robospice](https://github.com/stephanenicolas/robospice) <td width="275"> RoboSpice 是一个使你建立异步的长时间的运行任务异常轻松的一个网络库,在网络请求,缓存支持,和提供开箱即用的rest请求方面尤为强大 </td> 73. [hugo](https://github.com/JakeWharton/hugo) <td width="275"> Hugo 是 JakeWharton 大神推出的一个用于打印 Log, hugo 是基于注解被调用的, 引入相关依赖后, 在方法上加上 @DebugLog 即可输出 Log, 使用非常简单 </td> 74. [async-http-client](https://github.com/AsyncHttpClient/async-http-client) <td width="275"> AsyncHttpClient 是又一款 Android 异步请求库, 该库支持 WebSocket 协议, 使用起来也比较简单易用 </td> 75. [UltimateRecyclerView](https://github.com/cymcsg/UltimateRecyclerView) <td width="275"> UltimateRecyclerView 是一个功能强大的 RecyclerView(advanced and flexible version of ListView), 包括了下拉刷新, 加载更多, 多种动画, 空数据提示, 拖动排序, 视差处理, 工具栏渐变, 滑动删除, 自定义floating button, 多种刷新效果, scrollbar, sticky header, 多 layout 支持等等元素, 而且使用起来跟 RecyclerView 一样的方便 </td> 76. [MaterialEditText](https://github.com/rengwuxian/MaterialEditText) <td width="275"> MaterialEditText 是就职于 Flipboard 的员工 [扔物线](https://www.zhihu.com/people/rengwuxian) 开发的, 在 AppCompat v21 中也提供了 Material Design 的控件 EditText, 可是由于比较难用, 没有提供设置颜色的 Api, 于是就产生这个第三方库 </td> 77. [Side-Menu.Android](https://github.com/Yalantis/Side-Menu.Android) <td width="275"> Side Menu 是 [Yalantis](https://yalantis.com/) 组织开源出来, 该组织因开源出一些动画很棒的开源库为大家所熟知该库是其中一个, 该库是提供翻页动画效果的侧边菜单, 动画体验超赞的 </td> 78. [drag-sort-listview](https://github.com/bauerca/drag-sort-listview) <td width="275"> DragSortListView 是一个可以实现拖动排序, 滑动删除的 listview 控件, 注意的是作者对该库已经放弃维护更新了, 不过感兴趣的人可以去研究一下 </td> 79. [android-times-square](https://github.com/square/android-times-square) <td width="275"> TimesSquare 是 Square 公司出品的一款显示日历选择日期的控件, 可以让用户选择多个日期 </td> 80. [GreenDroid(不建议使用)](https://github.com/cyrilmottier/GreenDroid) <td width="275"> GreenDroid 是一个封装好的 Android UI 界面库, 不过该库已经被弃用了,不建议使用 </td> 81. [logger](https://github.com/orhanobut/logger) <td width="275"> Logger 是一个简单, 漂亮, 强大 Android 打印日志库 </td> 82. [acra](https://github.com/ACRA/acra) <td width="275"> Acra 是一个能够让 Android 应用自动将崩溃报告以谷歌文档电子表的形式进行发送的库, 旨在当应用发生崩溃或出现错误行为时, 开发者可以获取到相关数据 </td> 83. [FadingActionBar](https://github.com/ManuelPeinado/FadingActionBar) <td width="275"> FadingActionBar 是一个支持 ListView, ScrollView, WebView 向下滚动时逐渐显示 ActionBar 库 </td> 84. [AndroidImageSlider](https://github.com/daimajia/AndroidImageSlider) <td width="275"> AndroidImageSlider 库开发者是代码家, 该库是为 Banner 图片滑动提供多种动画效果, 还可以轻易为 Banner 加载网络图片 </td> 85. [SystemBarTint](https://github.com/jgilfelt/SystemBarTint) <td width="275"> SystemBarTint 是一个实现沉浸式状态栏库, 适用于 Android 系统 4.4 其以上的版本 </td> 86. [android-menudrawer](https://github.com/SimonVT/android-menudrawer) <td width="275"> MenuDrawer 是一款滑出式菜单库, 通过拖动屏幕边缘滑出菜单, 支持屏幕上下左右划出, 支持当前 View 处于上下层, 支持 Windows 边缘, ListView 边缘, ViewPager 变化划出菜单等 </td> 87. [RoundedImageView](https://github.com/vinc3m1/RoundedImageView) <td width="275"> RoundedImageView 一个快速支持图片圆角显示效果的库, 该库特点是能快速加载, 为了提高加载速度, 该库不用创建原始位图的副本, 不使用clipPath, 不使用 setXfermode 裁剪的位图等方式来实现 ImageView 圆角, 使用也非常简单 </td> 88. [afinal](https://github.com/yangfuhai/afinal) <td width="275"> Afinal 是一个 android 的 sqlite orm 和 ioc 框架, 同时封装了 android 中的 http 框架, 使其更加简单易用, 使用 finalBitmap, 无需考虑 bitmap 在 android 中加载的时候 oom 的问题和快速滑动的时候图片加载位置错位等问题, Afinal 的宗旨是简洁, 快速, 约定大于配置的方式, 尽量一行代码完成所有事情 </td> 89. [android-pulltorefresh(不建议使用)](https://github.com/johannilsson/android-pulltorefresh) <td width="275"> 另一个下拉刷新库, 但是该库已经停止维护, 因此不建议使用, 推荐使用 Android-Ultra-Pull-to-Refresh </td> 90. [Bolts-Android](https://github.com/BoltsFramework/Bolts-Android) <td width="275"> Bolts 是一款底层类库集合, 在后台实现异步操作, 并提供接口反馈当前异步执行的程度 (可以通过接口实现UI进度更新), 最后反馈执行的结果给UI主线程, 与AsyncTask比较: (1)使用的是无大小限制的线程池; (2)任务可组合可级联,防止了代码耦合 </td> 91. [NumberProgressBar](https://github.com/daimajia/NumberProgressBar) <td width="275"> NumberProgressBar 开发者是代码家, 这是一个带简约性感数字显示的进度条库, 使用非常简单方便 </td> 92. [SwipeBackLayout](https://github.com/ikew0ng/SwipeBackLayout) <td width="275"> SwipeBackLayout 是一个支持屏幕上下左右滑动返回上层 Activity, 关闭当前 Activity, 类似简书 App </td> 93. [android-gif-drawable](https://github.com/koral--/android-gif-drawable) <td width="275"> 一个支持 gif 显示的 view, 用 jni 实现的, 编译生成 so 库后直接 xml 定义 view 即可, 简单易用 </td> 94. [VitamioBundle](https://github.com/yixia/VitamioBundle) <td width="275"> Vitamio 是一款 Android 与 iOS 平台上的全能多媒体开发框架, 特点:(1) 全面支持硬件解码与 GPU 渲染, (2) 能够流畅播放 720P 甚至 1080P 高清 MKV, FLV, MP4, MOV, TS, RMVB 等常见格式的视频, (3) 在 Android 与 iOS 上跨平台支持 MMS, RTSP, RTMP, HLS(m3u8)等常见的多种视频流媒体协议, 包括点播与直播 </td> 95. [SmartTabLayout](https://github.com/ogaclejapan/SmartTabLayout) <td width="275"> SmartTabLayout 是一个自定义的 Tab title strip, 基于 Google Samples 中的 android-SlidingTabBasic 项目, 滑动时 Indicator 可平滑过渡 </td> 96. [uCrop](https://github.com/Yalantis/uCrop) <td width="275"> uCrop 是[Yalantis](https://yalantis.com/) 组织开源的图片裁剪库, 支持缩放, 旋转图片, 支持各种比例的裁剪框, 非常强大的一个图片裁剪库 </td> 97. [android-crop](https://github.com/jdamcd/android-crop) <td width="275"> 又一个图片裁剪库, 向下兼容到 Api 10, 个人感觉这个库并没有比上面介绍的 uCrop 强大 </td> 98. [HoloEveryWhere](https://github.com/Prototik/HoloEverywhere) <td width="275"> HoloEveryWhere 是一套 Android 开发库, 提供了全套 Holo Style 控件, 它的外观与功能和标准 Holo Style 控件基本相同, 唯一不同的是它可以运行在低于 4.0 版本的 Android 系统上 </td> 99. [AVLoadingIndicatorView](https://github.com/81813780/AVLoadingIndicatorView) <td width="275"> AVLoadingIndicatorView 库含有各种各样漂亮的加载动画效果, 使用起来也非常简单, 和平时使用 ProgressBar 一样 </td> 00. [sweet-alert-dialog](https://github.com/pedant/sweet-alert-dialog) <td width="275"> Android 版的 SweetAlert, 清新文艺, 快意灵动的甜心弹框, 灵感来源于 JS 版[SweetAlert](http://t4t5.github.io/sweetalert/) </td> {#user-content-粗计.anchor}粗计 {#user-content-square-公司占有-7-席.anchor}Square 公司占有 7 席 项目名称 <th> 排名 </th> [Retrofit](https://github.com/square/retrofit) <td width="130"> 4 </td> [OkHttp](https://github.com/square/okhttp) <td width="130"> 5 </td> [Picasso](https://github.com/square/picasso) <td width="130"> 7 </td> [LeakCanary](https://github.com/square/leakcanary) <td width="130"> 13 </td> [Dagger](https://github.com/square/dagger) <td width="130"> 29 </td> [Otto](https://github.com/square/otto) <td width="130"> 44 </td> [TimesSquare](https://github.com/square/android-times-square) <td width="130"> 79 </td> {#user-content-facebook-公司占有-4-席.anchor}FaceBook 公司占有 4 席 项目名称 <th> 排名 </th> [React Native](https://github.com/facebook/react-native) <td width="124"> 1 </td> [Fresco](https://github.com/facebook/fresco) <td width="124"> 11 </td> [Stetho](https://github.com/facebook/stetho) <td width="124"> 38 </td> [Rebound](https://github.com/facebook/rebound) <td width="124"> 62 </td> {#user-content-jakewharton-大神占有-5-席.anchor}JakeWharton 大神占有 5 席 项目名称 <th> 排名 </th> [Butter Knife](https://github.com/JakeWharton/butterknife) <td width="98"> 14 </td> [ActionBarSherlock](https://github.com/JakeWharton/ActionBarSherlock) <td width="98"> 16 </td> [ViewPagerIndicator](https://github.com/JakeWharton/ViewPagerIndicator) <td width="98"> 18 </td> [NineOldAndroids](https://github.com/JakeWharton/NineOldAndroids) <td width="98"> 55 </td> [Hugo](https://github.com/JakeWharton/hugo) <td width="98"> 73 </td> {#user-content-代码家大神占有-4-席.anchor}代码家大神占有 4 席 项目名称 <th> 排名 </th> [AndroidSwipeLayout](https://github.com/daimajia/AndroidSwipeLayout) <td width="89"> 28 </td> [AndroidViewAnimations](https://github.com/daimajia/AndroidViewAnimations) <td width="89"> 32 </td> [AndroidImageSlide](https://github.com/daimajia/AndroidImageSlider) <td width="89"> 84 </td> [NumberProgressBar](https://github.com/daimajia/NumberProgressBar) <td width="89"> 91 </td> 转自:http://www.lesscode.cn/index.php?s=/view-index-id-299.shtml ...

2016年3月15日 · 9 分钟 · 天边的星星

Github上README.md介绍

大标题 大标题一般显示工程名,类似html的<h1> 你只要在标题下面跟上=====即可 中标题 ———————————– 中标题一般显示重点项,类似html的<h2> 你只要在标题下面输入——即可 ### 小标题 小标题类似html的<h3> 小标题的格式如下 ### 小标题 注意#和标题字符中间要有空格 ### 注意!!!下面所有语法的提示我都先用小标题提醒了!!! ### 单行文本框 这是一个单行的文本框,只要两个Tab再输入文字即可 ### 多行文本框 这是一个有多行的文本框 你可以写入代码等,每行文字只要输入两个Tab再输入文字即可 这里你可以输入一段代码 ### 比如我们可以在多行文本框里输入一段代码,来一个Java版本的HelloWorld吧 public class HelloWorld { /** @param args */ public static void main(String[] args) { System.out.println(“HelloWorld!”); } } ### 链接 1.[点击这里你可以链接到www.google.com](http://www.google.com) 2.[点击这里我你可以链接到我的博客](http://guoyunsky.iteye.com) ###只是显示图片 ![github](http://github.com/unicorn.png “github”) ###想点击某个图片进入一个网页,比如我想点击github的icorn然后再进入www.github.com [![image]](http://www.github.com/) [image]: http://github.com/github.png “github” ### 文字被些字符包围 文字被些字符包围 只要再文字前面加上>空格即可 如果你要换行的话,新起一行,输入>空格即可,后面不接文字 但> 只能放在行首才有效 ### 文字被些字符包围,多重包围 文字被些字符包围开始 只要再文字前面加上>空格即可 如果你要换行的话,新起一行,输入>空格即可,后面不接文字 但> 只能放在行首才有效 ### 特殊字符处理 有一些特殊字符如<,#等,只要在特殊字符前面加上转义字符\即可 ...

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

GitHub控件之BadgeView(数字提醒)

数字提醒大家肯定都见识过。QQ、微信等app中如果有消息或者提醒的时候,就会展现给用户一个红点或者带有数字的点。前段时间微信上流行把自己的头像换成带有数字提醒的头像,让那些有强迫症的人真是抓狂。 下面我们就看一下怎么在自己的app中实现这种效果。 开发者当然可以自己用相对布局来实现这样的效果。一个还好,但是多了呢!就会很繁琐。GitHub上有一个开源的第三方控件,叫做BadgeView。使用它可以很方面的实现想要的效果。 先来怎么使用,简单的三行代码就可以实现数字提醒: **[java]** [view plain](http://blog.csdn.net/crazy1235/article/details/42262369#)[copy](http://blog.csdn.net/crazy1235/article/details/42262369#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/571341)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/571341/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> - BadgeView badgeView = <span class="keyword">new</span> com.jauker.widget.BadgeView(<span class="keyword">this</span>); - badgeView.setTargetView(textView); - badgeView.setBadgeCount(<span class="number">3</span>); 看一下badgeview中常用的方法: **[java]** [view plain](http://blog.csdn.net/crazy1235/article/details/42262369#)[copy](http://blog.csdn.net/crazy1235/article/details/42262369#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/571341)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/571341/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> - badgeView = <span class="keyword">new</span> BadgeView(<span class="keyword">this</span>); - badgeView.setTargetView(layout); - badgeView.setBackground(<span class="number">12</span>, Color.parseColor(<span class="string">&#8220;#9b2eef&#8221;</span>)); - badgeView.setText(<span class="string">&#8220;提示&#8221;</span>); ...

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

oschina-app源码分析-提醒标签BadgeView使用方法https://github.com/chenupt/BezierDemo

看过oschina-app的数字提醒标签BadgeView的使用过程,才发现以前项目中的实现逻辑有问题。以前待的项目组没个牛人,从我干第一个项目就我负责开发设计和管理,可想而知,顶多也就实现功能交工。说到底就是经验不足,所以有时间还是多看看别人的代码。本来是想主要讲oschina-app里面提醒标签的实现逻辑,但我觉得标签控件BadgeView有必要说下。 BadgeView是一个开源的ui项目,其实就一个ui工具类,BadgeView是对TextView的重写,他的代码就不贴了,可以到git上下最新的吧:https://github.com/jgilfelt/android-viewbadger 在这里主要说下他的用法,它可以设置标签的背景、颜色、位置、动画、文字等,对一般的需求足以满足了,先看下git上demo的效果: 默认属性标签代码: **[java]** [view plain](http://blog.csdn.net/xiangxue336/article/details/21073571#)[copy](http://blog.csdn.net/xiangxue336/article/details/21073571#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/230977)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/230977/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="comment">// *** default badge ***</span> - - View target = findViewById(R.id.default_target); - BadgeView badge = <span class="keyword">new</span> BadgeView(<span class="keyword">this</span>, target); - badge.setText(<span class="string">&#8220;1&#8221;</span>); - badge.show(); 默认是显示在右上角,红色的背景白色字体,这些个默认属性是可以在BadgeView里面设置的。 设置position代码: **[java]** [view plain](http://blog.csdn.net/xiangxue336/article/details/21073571#)[copy](http://blog.csdn.net/xiangxue336/article/details/21073571#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/230977)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/230977/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> - <span class="comment">// *** set position ***</span> - - btnPosition = (Button) findViewById(R.id.position_target); - badge1 = <span class="keyword">new</span> BadgeView(<span class="keyword">this</span>, btnPosition); - badge1.setText(<span class="string">&#8220;12&#8221;</span>); - badge1.setBadgePosition(BadgeView.POSITION_CENTER); - btnPosition.setOnClickListener(<span class="keyword">new</span> OnClickListener() { - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onClick(View v) { - badge1.toggle(); - } - }); toggle方法是控制标签的现实和隐藏的。 ...

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

github源码分享PinnedSectionListView:分组的listView滑动中固定组标题的实现

在很多应用中,看到这样的listview:listview滑动过程中分组标题固定在上方,当第二个组滑上来时,第一个组才跟着上滑,下一个组固定,直到该组也滑出上边缘。世上无难事只怕有心人,在github上就有人做出来了,而且效果很好(后来发现安卓自带应用中联系人应用就是这样的,估计github的作者也是仿照着联系人做出来的吧)。 先看截图: PinnedSectionListView继承自listview,众所周知listview的每个子view都是按顺序跟着滚动的,要实现联系人listview的效果还真的找不到思路。看了PinnedSectionListView之后,感觉要改造一个现有的控件,一般都是通过重绘子view来实现的。ViewGroup(ListView继承自它)重绘子view的方法是dispatchDraw。 看看PinnedSectionListView在dispatchDraw中有那些特别的处理: 1 <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> <div class="line number6 index5 alt1"> 6 </div> <div class="line number7 index6 alt2"> 7 </div> <div class="line number8 index7 alt1"> 8 </div> <div class="line number9 index8 alt2"> 9 </div> <div class="line number10 index9 alt1"> 10 </div> <div class="line number11 index10 alt2"> 11 </div> <div class="line number12 index11 alt1"> 12 </div> <div class="line number13 index12 alt2"> 13 </div> <div class="line number14 index13 alt1"> 14 </div> <div class="line number15 index14 alt2"> 15 </div> <div class="line number16 index15 alt1"> 16 </div> <div class="line number17 index16 alt2"> 17 </div> <div class="line number18 index17 alt1"> 18 </div> <div class="line number19 index18 alt2"> 19 </div> <div class="line number20 index19 alt1"> 20 </div> <div class="line number21 index20 alt2"> 21 </div> <div class="line number22 index21 alt1"> 22 </div> <div class="line number23 index22 alt2"> 23 </div> <div class="line number24 index23 alt1"> 24 </div> <div class="line number25 index24 alt2"> 25 </div> </td> <td class="code"> <div class="container"> <div class="line number1 index0 alt2"> `@Override` </div> <div class="line number2 index1 alt1"> `protected void dispatchDraw(Canvas canvas) {` </div> <div class="line number3 index2 alt2"> ` ``super``.dispatchDraw(canvas);` </div> <div class="line number4 index3 alt1"> ` ``if` `(mPinnedSection != ``null``) {` </div> <div class="line number5 index4 alt2"> ` ``// prepare variables` </div> <div class="line number6 index5 alt1"> ` ``int pLeft = getListPaddingLeft();` </div> <div class="line number7 index6 alt2"> ` ``int pTop = getListPaddingTop();` </div> <div class="line number8 index7 alt1"> ` ``View view = mPinnedSection.view;` </div> <div class="line number9 index8 alt2"> ` ``// draw child` </div> <div class="line number10 index9 alt1"> ` ``canvas.save();` </div> <div class="line number11 index10 alt2"> ` ``int clipHeight = view.getHeight() +` </div> <div class="line number12 index11 alt1"> ` ``(mShadowDrawable == ``null` `? 0 : Math.min(mShadowHeight, mSectionsDistanceY));` </div> <div class="line number13 index12 alt2"> ` ``canvas.clipRect(pLeft, pTop, pLeft + view.getWidth(), pTop + clipHeight);` </div> <div class="line number14 index13 alt1"> ` ``canvas.translate(pLeft, pTop + mTranslateY);` </div> <div class="line number15 index14 alt2"> ` ``drawChild(canvas, mPinnedSection.view, getDrawingTime());` </div> <div class="line number16 index15 alt1"> ` ``if` `(mShadowDrawable != ``null` `&& mSectionsDistanceY &gt; 0) {` </div> <div class="line number17 index16 alt2"> ` ``mShadowDrawable.setBounds(mPinnedSection.view.getLeft(),` </div> <div class="line number18 index17 alt1"> ` ``mPinnedSection.view.getBottom(),` </div> <div class="line number19 index18 alt2"> ` ``mPinnedSection.view.getRight(),` </div> <div class="line number20 index19 alt1"> ` ``mPinnedSection.view.getBottom() + mShadowHeight);` </div> <div class="line number21 index20 alt2"> ` ``mShadowDrawable.draw(canvas);` </div> <div class="line number22 index21 alt1"> ` ``}` </div> <div class="line number23 index22 alt2"> ` ``canvas.restore();` </div> <div class="line number24 index23 alt1"> ` ``}` </div> <div class="line number25 index24 alt2"> `}` </div> </div> </td> </tr> </table> 关键在于```canvas.translate(pLeft, pTop + mTranslateY);意思是在绘制mPinnedSection的时候,listview滑动了多长的距离,就将canvas移动多少的距离,使mPinnedSection`始终在可见的范围内固定不变。 ...

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