Android Paint之 setXfermode PorterDuffXfermode 讲解,androidsetxfermode

转载来自: http://blog.csdn.net/tianjian4592 前面关于paint的方法讲解里,讲到 setXfermode 就截止了,原因有两个: 那篇文章已经太长了,我自己都看不下去了; 2. setXfermode 在paint 里占有至关重要的地位; 基于以上两个原因,我们一起来看看这个方法有何妙用。 首先我们还是来看看关于这个方法的说明: /** * Set or clear the xfermode object. - 设置或清除xfermode对象; * Pass null to clear any previous xfermode. - 传递null以清除任何以前的xfermode。 * As a convenience, the parameter passed is also returned. - 为方便起见,也返回传递的参数。 * * @return xfermode */ public Xfermode setXfermode(Xfermode xfermode) { int xfermodeNative = 0; if (xfermode != null) xfermodeNative = xfermode.native_instance; native_setXfermode(mNativePaint, xfermodeNative); mXfermode = xfermode; return xfermode; } 这个方法传进一个 Xfermode 对象,而打开 Xfermode 发现里面没有提供任何可用的构造函数或方法,ctrl +T 看到它有三个子类: ...

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

Android 快速开发系列 ORMLite 框架最佳实践

转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/39122981,本文出自【张鸿洋的博客】 上一篇已经对ORMLite框架做了简单的介绍:Android ORMLite 框架的入门用法~~本篇将介绍项目可能会使用到的一些用法,也为我们的使用ORMLite框架总结出一个较合理的用法。 通过上一篇的了解,我们使用ORMLite,需要自己写一个DatabaseHelper去继承OrmLiteSqliteOpenHelper,下面我们首先给出一个我认为比较靠谱的Helper的写法: 1、DatabaseHelper **[java]** [view plain](http://blog.csdn.net/lmj623565791/article/details/39122981#)[copy](http://blog.csdn.net/lmj623565791/article/details/39122981#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/465469)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/465469/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">package</span> com.zhy.zhy_ormlite.db; - - <span class="keyword">import</span> java.sql.SQLException; - <span class="keyword">import</span> java.util.HashMap; - <span class="keyword">import</span> java.util.Map; - - <span class="keyword">import</span> android.content.Context; - <span class="keyword">import</span> android.database.sqlite.SQLiteDatabase; - - <span class="keyword">import</span> com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; - <span class="keyword">import</span> com.j256.ormlite.dao.Dao; - <span class="keyword">import</span> com.j256.ormlite.support.ConnectionSource; - <span class="keyword">import</span> com.j256.ormlite.table.TableUtils; - <span class="keyword">import</span> com.zhy.zhy_ormlite.bean.Article; - <span class="keyword">import</span> com.zhy.zhy_ormlite.bean.Student; - <span class="keyword">import</span> com.zhy.zhy_ormlite.bean.User; - - <span class="keyword">public</span> <span class="keyword">class</span> DatabaseHelper <span class="keyword">extends</span> OrmLiteSqliteOpenHelper - { - <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String TABLE_NAME = <span class="string">&#8220;sqlite-test.db&#8221;</span>; - - <span class="keyword">private</span> Map<String, Dao> daos = <span class="keyword">new</span> HashMap<String, Dao>(); - - <span class="keyword">private</span> DatabaseHelper(Context context) - { - <span class="keyword">super</span>(context, TABLE_NAME, <span class="keyword">null</span>, <span class="number">4</span>); - } - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onCreate(SQLiteDatabase database, - ConnectionSource connectionSource) - { - <span class="keyword">try</span> - { - TableUtils.createTable(connectionSource, User.<span class="keyword">class</span>); - TableUtils.createTable(connectionSource, Article.<span class="keyword">class</span>); - TableUtils.createTable(connectionSource, Student.<span class="keyword">class</span>); - } <span class="keyword">catch</span> (SQLException e) - { - e.printStackTrace(); - } - } - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onUpgrade(SQLiteDatabase database, - ConnectionSource connectionSource, <span class="keyword">int</span> oldVersion, <span class="keyword">int</span> newVersion) - { - <span class="keyword">try</span> - { - TableUtils.dropTable(connectionSource, User.<span class="keyword">class</span>, <span class="keyword">true</span>); - TableUtils.dropTable(connectionSource, Article.<span class="keyword">class</span>, <span class="keyword">true</span>); - TableUtils.dropTable(connectionSource, Student.<span class="keyword">class</span>, <span class="keyword">true</span>); - onCreate(database, connectionSource); - } <span class="keyword">catch</span> (SQLException e) - { - e.printStackTrace(); - } - } - - <span class="keyword">private</span> <span class="keyword">static</span> DatabaseHelper instance; - - <span class="comment">/**</span> - <span class="comment"> * 单例获取该Helper</span> - <span class="comment"> * </span> - <span class="comment"> * @param context</span> - <span class="comment"> * @return</span> - <span class="comment"> */</span> - <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">synchronized</span> DatabaseHelper getHelper(Context context) - { - context = context.getApplicationContext(); - <span class="keyword">if</span> (instance == <span class="keyword">null</span>) - { - <span class="keyword">synchronized</span> (DatabaseHelper.<span class="keyword">class</span>) - { - <span class="keyword">if</span> (instance == <span class="keyword">null</span>) - instance = <span class="keyword">new</span> DatabaseHelper(context); - } - } - - <span class="keyword">return</span> instance; - } - - <span class="keyword">public</span> <span class="keyword">synchronized</span> Dao getDao(Class clazz) <span class="keyword">throws</span> SQLException - { - Dao dao = <span class="keyword">null</span>; - String className = clazz.getSimpleName(); - - <span class="keyword">if</span> (daos.containsKey(className)) - { - dao = daos.get(className); - } - <span class="keyword">if</span> (dao == <span class="keyword">null</span>) - { - dao = <span class="keyword">super</span>.getDao(clazz); - daos.put(className, dao); - } - <span class="keyword">return</span> dao; - } - - <span class="comment">/**</span> - <span class="comment"> * 释放资源</span> - <span class="comment"> */</span> - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> close() - { - <span class="keyword">super</span>.close(); - - <span class="keyword">for</span> (String key : daos.keySet()) - { - Dao dao = daos.get(key); - dao = <span class="keyword">null</span>; - } - } - - } 1、整个DatabaseHelper使用单例只对外公布出一个对象,保证app中只存在一个SQLite Connection , 参考文章:http://www.touchlab.co/2011/10/single-sqlite-connection/ ...

2015年8月5日 · 10 分钟 · 天边的星星

Android使用UncaughtExceptionHandler捕获全局异常

Android系统的“程序异常退出”,给应用的用户体验造成不良影响。为了捕获应用运行时异常并给出友好提示,便可继承UncaughtExceptionHandler类来处理。通过Thread.setDefaultUncaughtExceptionHandler()方法将异常处理类设置到线程上即可。 1、异常处理类,代码如下: **[java]** [view plain](http://blog.csdn.net/hehe9737/article/details/7662123#)[copy](http://blog.csdn.net/hehe9737/article/details/7662123#) <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">public</span> <span class="keyword">class</span> CrashHandler <span class="keyword">implements</span> UncaughtExceptionHandler { - <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">final</span> String TAG = <span class="string">&#8220;CrashHandler&#8221;</span>; - <span class="keyword">private</span> <span class="keyword">static</span> CrashHandler INSTANCE = <span class="keyword">new</span> CrashHandler(); - <span class="keyword">private</span> Context mContext; - <span class="keyword">private</span> Thread.UncaughtExceptionHandler mDefaultHandler; - - <span class="keyword">private</span> CrashHandler() { - } - - <span class="keyword">public</span> <span class="keyword">static</span> CrashHandler getInstance() { - <span class="keyword">return</span> INSTANCE; - } - - <span class="keyword">public</span> <span class="keyword">void</span> init(Context ctx) { - mContext = ctx; - mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); - Thread.setDefaultUncaughtExceptionHandler(<span class="keyword">this</span>); - } - - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> uncaughtException(Thread thread, Throwable ex) { - <span class="comment">// if (!handleException(ex) && mDefaultHandler != null) {</span> - <span class="comment">// mDefaultHandler.uncaughtException(thread, ex);</span> - <span class="comment">// } else {</span> - <span class="comment">// android.os.Process.killProcess(android.os.Process.myPid());</span> - <span class="comment">// System.exit(10);</span> - <span class="comment">// }</span> - System.out.println(<span class="string">&#8220;uncaughtException&#8221;</span>); - - <span class="keyword">new</span> Thread() { - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> run() { - Looper.prepare(); - <span class="keyword">new</span> AlertDialog.Builder(mContext).setTitle(<span class="string">&#8220;提示&#8221;</span>).setCancelable(<span class="keyword">false</span>) - .setMessage(<span class="string">&#8220;程序崩溃了&#8230;&#8221;</span>).setNeutralButton(<span class="string">&#8220;我知道了&#8221;</span>, <span class="keyword">new</span> OnClickListener() { - <span class="annotation">@Override</span> - <span class="keyword">public</span> <span class="keyword">void</span> onClick(DialogInterface dialog, <span class="keyword">int</span> which) { - System.exit(<span class="number"></span>); - } - }) - .create().show(); - Looper.loop(); - } - }.start(); - } - - <span class="comment">/**</span> - <span class="comment"> * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成. 开发者可以根据自己的情况来自定义异常处理逻辑</span> - <span class="comment"> *</span> - <span class="comment"> * @param ex</span> - <span class="comment"> * @return true:如果处理了该异常信息;否则返回false</span> - <span class="comment"> */</span> - <span class="keyword">private</span> <span class="keyword">boolean</span> handleException(Throwable ex) { - <span class="keyword">if</span> (ex == <span class="keyword">null</span>) { - <span class="keyword">return</span> <span class="keyword">true</span>; - } - <span class="comment">// new Handler(Looper.getMainLooper()).post(new Runnable() {</span> - <span class="comment">// @Override</span> - <span class="comment">// public void run() {</span> - <span class="comment">// new AlertDialog.Builder(mContext).setTitle(&#8220;提示&#8221;)</span> - <span class="comment">// .setMessage(&#8220;程序崩溃了&#8230;&#8221;).setNeutralButton(&#8220;我知道了&#8221;, null)</span> - <span class="comment">// .create().show();</span> - <span class="comment">// }</span> - <span class="comment">// });</span> - - <span class="keyword">return</span> <span class="keyword">true</span>; - } - } 2、线程绑定异常处理类 ...

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

Android studio使用Annotations框架

首页创建Android studio项目 在项目的build.gradle中添加如下代码(如此简单) buildscript { repositories { mavenCentral() } dependencies { // replace with the current version of the Android plugin classpath ‘com.android.tools.build:gradle:1.2.3’ // the latest version of the android-apt plugin classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.4’ } } repositories { mavenCentral() mavenLocal() } apply plugin: ‘com.android.application’ apply plugin: ‘android-apt’ def AAVersion = ‘3.3.2’//这个是Annotations的版本号,这个可以去Annotations官网查看,也可以在Android studio中Jcenter或者mavenCentral中查找最新版本号 dependencies { compile fileTree(include: [‘*.jar’], dir: ‘libs’) compile ‘com.android.support:appcompat-v7:22.2.0’ apt “org.androidannotations:androidannotations:AAVersion” compile “org.androidannotations:androidannotations-api:AAVersion” } apt { arguments { androidManifestFile variant.outputs[0].processResources.manifestFile // if you have multiple outputs (when using splits), you may want to have other index than 0 ...

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

Android实现推送方式解决方案

** 本文介绍在Android中实现推送方式的基础知识及相关解决方案。推送功能在手机开发中应用的场景是越来起来了,不说别的,就我们手机上的新闻客户端就时不j时的推送过来新的消息,很方便的阅读最新的新闻信息。这种推送功能是好的一面,但是也会经常看到很多推送过来的垃圾信息,这就让我们感到厌烦了,关于这个我们就不能多说什么了,毕竟很多商家要做广告。本文就是来探讨下Android中实现推送功能的一些解决方案,也希望能够起到抛砖引玉的作用。^_^** ** 1.推送方式基础知识: ** 在移动互联网时代以前的手机,如果有事情发生需要通知用户,则会有一个窗口弹出,将告诉用户正在发生什么事情。可能是未接电话的提示,日历的提醒,或是一封新的彩信。推送功能最早是被用于Email中,用来提示我们新的信息。由于时代的发展和移动互联网的热潮,推送功能更加地普及,已经不再仅仅用在推送邮件了,更多地用在我们的APP中了。 当我们开发需要和服务器交互的应用程序时,基本上都需要获取服务器端的数据,比如《地震应急通》就需要及时获取服务器上最新的地震信息。要获取服务器上不定时更新的信息,一般来说有两种方法:第一种是客户端使用Pull(拉)的方式,就是隔一段时间就去服务器上获取一下信息,看是否有更新的信息出现。第二种就是 服务器使用Push(推送)的方式,当服务器端有新信息了,则把最新的信息Push到客户端上。这样,客户端就能自动的接收到消息。 虽然Pull和Push两种方式都能实现获取服务器端更新信息的功能,但是明显来说Push方式比Pull方式更优越。因为Pull方式更费客户端的网络流量,更主要的是费电量,还需要我们的程序不停地去监测服务端的变化。 在开发Android和iPhone应用程序时,我们往往需要从服务器不定的向手机客户端即时推送各种通知消息。我们只需要在Android或IPhone的通知栏处向下一拉,就展开了Notification Panel,可以集中一览各种各样通知消息。目前IOS平台上已经有了比较简单的和完美的推送通知解决方案,我会在以后详细介绍IPhone中的解决方案,可是Android平台上实现起来却相对比较麻烦。 最近利用几天的时间对Android的推送通知服务进行初步的研究,也希望能和大家共同探讨一下。 ** 2. 几种常见的解决方案实现原理:** 1)轮询(Pull)方式:应用程序应当阶段性的与服务器进行连接并查询是否有新的消息到达,你必须自己实现与服务器之间的通信,例如消息排队等。而且你还要考虑轮询的频率,如果太慢可能导致某些消息的延迟,如果太快,则会大量消耗网络带宽和电池。 2)SMS(Push)方式:在Android平台上,你可以通过拦截SMS消息并且解析消息内容来了解服务器的意图,并获取其显示内容进行处理。这是一个不错的想法,我就见过采用这个方案的应用程序。这个方案的好处是,可以实现完全的实时操作。但是问题是这个方案的成本相对比较高,我们需要向移动公司缴纳相应的费用。我们目前很难找到免费的短消息发送网关来实现这种方案。 3)持久连接(Push)方式:这个方案可以解决由轮询带来的性能问题,但是还是会消耗手机的电池。IOS平台的推送服务之所以工作的很好,是因为每一台手机仅仅保持一个与服务器之间的连接,事实上C2DM也是这么工作的。不过刚才也讲了,这个方案存在着很多的不足之处,就是我们很难在手机上实现一个可靠的服务,目前也无法与IOS平台的推送功能相比。 Android操作系统允许在低内存情况下杀死系统服务,所以我们的推送通知服务很有可能就被操作系统Kill掉了。 轮询(Pull)方式和SMS(Push)方式这两个方案也存在明显的不足。至于持久连接(Push)方案也有不足,不过我们可以通过良好的设计来弥补,以便于让该方案可以有效的工作。毕竟,我们要知道GMail,GTalk以及GoogleVoice都可以实现实时更新的。 3.第一种解决方案:C2DM云端推送功能。 在Android手机平台上,Google提供了C2DM(Cloudto Device Messaging)服务,起初我就是准备采用这个服务来实现自己手机上的推送功能,并将其带入自己的项目中。 Android Cloud to Device Messaging (C2DM)是一个用来帮助开发者从服务器向Android应用程序发送数据的服务。该服务提供了一个简单的、轻量级的机制,允许服务器可以通知移动应用程序直接与服务器进行通信,以便于从服务器获取应用程序更新和用户数据。C2DM服务负责处理诸如消息排队等事务并向运行于目标设备上的应用程序分发这些消息。关于C2DM具体使用过程,大家可以去查阅相关的资料,在这里先让我们了解下大致方案情况。 下面是C2DM操作过程示例图: 但是经过一番研究发现,这个服务存在很大的问题: 1)C2DM内置于Android的2.2系统上,无法兼容老的1.6到2.1系统; 2)C2DM需要依赖于Google官方提供的C2DM服务器,由于国内的网络环境,这个服务经常不可用,如果想要很好的使用,我们的App Server必须也在国外,这个恐怕不是每个开发者都能够实现的; 3) 不像在iPhone中,他们把硬件系统集成在一块了。所以对于我们开发者来说,如果要在我们的应用程序中使用C2DM的推送功能,因为对于不同的这种硬件厂商平台,比如摩托罗拉、华为、中兴做一个手机,他们可能会把Google的这种服务去掉,尤其像在国内就很多这种,把Google这种原生的服务去掉。买了一些像什么山寨机或者是华为这种国产机,可能Google的服务就没有了。而像在国外出的那些可能会内置。 有了上述几个方面的制约,导致我最终放弃了这个方案,不过我想利用另外一篇文章来详细的介绍C2DM的框架以及客户端和App Server的相应设置方法,可以作为学习资源让我们有个参考的资料。 即然C2DM无法满足我们的要求,那么我们就需要自己来实现Android手机客户端与App Server之间的通信协议,保证在App Server想向指定的Android设备发送消息时,Android设备能够及时的收到。 ** 4. **第二种解决方案:MQTT协议实现Android推送功能。 采用MQTT协议实现Android推送功能也是一种解决方案。MQTT是一个轻量级的消息发布/订阅协议,它是实现基于手机客户端的消息推送服务器的理想解决方案。 wmqtt.jar 是IBM提供的MQTT协议的实现。我们可以从这里(https://github.com/tokudu/AndroidPushNotificationsDemo)下载该项目的实例代码,并且可以找到一个采用PHP书写的服务器端实现(https://github.com/tokudu/PhpMQTTClient)。 架构如下图所示: ** wmqtt.jar** 是IBM提供的MQTT协议的实现。我们可以从如下站点下载(http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg24006006)它。我们可以将该jar包加入自己的Android应用程序中。 ** 5.**第三种解决方案:RSMB实现推送功能。 Really Small Message Broker (RSMB) ,他是一个简单的MQTT代理,同样由IBM提供,其查看地址是:http://www.alphaworks.ibm.com/tech/rsmb。缺省打开1883端口,应用程序当中,它负责接收来自服务器的消息并将其转发给指定的移动设备。 SAM是一个针对MQTT写的[PHP库](http://pecl.php.net/package/sam/download/0.2.0)。我们可以从这个[http://pecl.php.net/package/sam/download/0.2.](http://pecl.php.net/package/sam/download/0.2.)[](http://pecl.php.net/package/sam/download/0.2.0)地址下载它. send_mqtt.php是一个通过POST接收消息并且通过SAM将消息发送给RSMB的PHP脚本。 ** 6. **第四种解决方案:XMPP协议实现Android推送功能。 这是我希望在项目中采用的方案,因为目前它是开源的,对于其简单的推送功能它还是能够实现的。我们可以修改其源代码来适应我们的应用程序。 ...

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

Android自定义控件

开发自定义控件的步骤: 1、了解View的工作原理 2、 编写继承自View的子类 3、 为自定义View类增加属性 4、 绘制控件 5、 响应用户消息 6 、自定义回调函数 一、View结构原理 Android系统的视图结构的设计也采用了组合模式,即View作为所有图形的基类,Viewgroup对View继承扩展为视图容器类。 View定义了绘图的基本操作 基本操作由三个函数完成:measure()、layout()、draw(),其内部又分别包含了onMeasure()、onLayout()、onDraw()三个子方法。具体操作如下: 1、measure操作 measure操作主要用于计算视图的大小,即视图的宽度和长度。在view中定义为final类型,要求子类不能修改。measure()函数中又会调用下面的函数: (1)onMeasure(),视图大小的将在这里最终确定,也就是说measure只是对onMeasure的一个包装,子类可以覆写onMeasure()方法实现自己的计算视图大小的方式,并通过setMeasuredDimension(width, height)保存计算结果。 2、layout操作 layout操作用于设置视图在屏幕中显示的位置。在view中定义为final类型,要求子类不能修改。layout()函数中有两个基本操作: (1)setFrame(l,t,r,b),l,t,r,b即子视图在父视图中的具体位置,该函数用于将这些参数保存起来; (2)onLayout(),在View中这个函数什么都不会做,提供该函数主要是为viewGroup类型布局子视图用的; 3、draw操作 draw操作利用前两部得到的参数,将视图显示在屏幕上,到这里也就完成了整个的视图绘制工作。子类也不应该修改该方法,因为其内部定义了绘图的基本操作: (1)绘制背景; (2)如果要视图显示渐变框,这里会做一些准备工作; (3)绘制视图本身,即调用onDraw()函数。在view中onDraw()是个空函数,也就是说具体的视图都要覆写该函数来实现自己的显示(比如TextView在这里实现了绘制文字的过程)。而对于ViewGroup则不需要实现该函数,因为作为容器是“没有内容“的,其包含了多个子view,而子View已经实现了自己的绘制方法,因此只需要告诉子view绘制自己就可以了,也就是下面的dispatchDraw()方法; (4)绘制子视图,即dispatchDraw()函数。在view中这是个空函数,具体的视图不需要实现该方法,它是专门为容器类准备的,也就是容器类必须实现该方法; (5)如果需要(应用程序调用了setVerticalFadingEdge或者setHorizontalFadingEdge),开始绘制渐变框; (6)绘制滚动条; 从上面可以看出自定义View需要最少覆写onMeasure()和onDraw()两个方法。 二、View类的构造方法 创建自定义控件的3种主要实现方式: 1)继承已有的控件来实现自定义控件: 主要是当要实现的控件和已有的控件在很多方面比较类似, 通过对已有控件的扩展来满足要求。 2)通过继承一个布局文件实现自定义控件,一般来说做组合控件时可以通过这个方式来实现。 注意此时不用onDraw方法,在构造广告中通过inflater加载自定义控件的布局文件,再addView(view),自定义控件的图形界面就加载进来了。 3)通过继承view类来实现自定义控件,使用GDI绘制出组件界面,一般无法通过上述两种方式来实现时用该方式。 三、自定义View增加属性的两种方法: 1)在View类中定义。通过构造函数中引入的AttributeSet 去查找XML布局的属性名称,然后找到它对应引用的资源ID去找值。 案例:实现一个带文字的图片(图片、文字是onDraw方法重绘实现) ![](http://common.cnblogs.com/images/copycode.gif) publicclassMyViewextendsView {privateString mtext;privateintmsrc;publicMyView(Context context) {super(context); }publicMyView(Context context, AttributeSet attrs) {super(context, attrs);intresourceId = 0;inttextId = attrs.getAttributeResourceValue(null, “Text”,0);intsrcId = attrs.getAttributeResourceValue(null, “Src”, 0); mtext=context.getResources().getText(textId).toString(); msrc=srcId; } @OverrideprotectedvoidonDraw(Canvas canvas) { ...

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

Android studio第一次导入项目遇到的问题,和解决方案

在github或者其他的git平台下载的android studio项目导入到自己的Android studio中会出现一堆问题, 首先在导入之前先用自己的Android studio创建一个测试工程,主要使用测试工程下的2个文件,分别是:./build.gradle和./gradle/wrapper/gradle-wrapper.properties文件 例如1.build.gradle dependencies { classpath ‘com.android.tools.build:gradle:1.2.3’ } 修改classpath中的gradle修改为你当前android studio环境中的配置 例如2.gradle/wrapper/gradle-wrapper.properties distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip 替换文件中的这句话,使用自己Android studio中相应语句 修改完成以上以后,打开Android studio选择/import project按照提示导入。 如何遇到导入的项目没有办法运行,这个时候我们运行 build/Rebuild Project进行重新编译项目。 在此过程中遇到 FAILURE: Build failed with an exception. What went wrong: Task ‘build.gradle’ not found in root project ‘XXX’. Try: 说明我们导入的项目还没有符合我们的环境,我们需要进一步配置。 打开cmd ,进入项目更目录执行 gradlew gradlew build 检查环境变量是否配置了gradle环境,没有自己配置下,在执行gradlew时会出现解压的目录地址,自己手动配置到环境变量就行了。 紧接着执行 gradle build gradle tasks //查看android gradle的所有任务 gradle compileReleaseSource //生成debug apk ,在build/outpus/apk 文件夹下 (下面2句可以不执行) 到此项目导入配置完成,关闭项目,使用Android studio重新打开项目,如果能开到某个文件夹上面有一个手机图标,恭喜你,项目配置成功了。 备注:以上命令可以在Android studio中的Terminal中执行。

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

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 分钟 · 天边的星星

Proguard keep static Inner Class Proguard keep一个 静态内部类的时候

今天在使用Proguard keep一个 静态内部类的时候,混淆完之后一直找不到那个静态内部类,内心抓狂啊。 最后在stackoverflow上找到了答案: **[html]** [view plain](http://blog.csdn.net/top_code/article/details/18225501#)[copy](http://blog.csdn.net/top_code/article/details/18225501#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/154763)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/154763/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> - -keepattributes Exceptions,InnerClasses,&#8230; - -keep class [packagename].A{ - *; - } - -keep class [packagename].A$* { - *; - } 其中 A$* 表示所有A的内部类都保留下来,也可以如下使用: **[html]** [view plain](http://blog.csdn.net/top_code/article/details/18225501#)[copy](http://blog.csdn.net/top_code/article/details/18225501#)[![在CODE上查看代码片](https://code.csdn.net/assets/CODE_ico.png)](https://code.csdn.net/snippets/154763)[![派生到我的代码片](https://code.csdn.net/assets/ico_fork.svg)](https://code.csdn.net/snippets/154763/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> - -keepattributes Exceptions,InnerClasses,&#8230; - -keep class com.xxx.A{ *; } - -keep class com.xxx.A$B { *; } - -keep class com.xxx.A$C { *; } ...

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

Android中常见的热门标签的流式布局的实现

一、概述: 在日常的app使用中,我们会在android 的app中看见 热门标签等自动换行的流式布局,今天,我们就来看看如何 自定义一个类似热门标签那样的流式布局吧(源码下载在下面最后给出) 类似的自定义布局。下面我们就来详细介绍流式布局的应用特点以及用的的技术点: 1.流式布局的特点以及应用场景 特点:当上面一行的空间不够容纳新的TextView时候, 才开辟下一行的空间 原理图: 场景:主要用于关键词搜索或者热门标签等场景 2.自定义ViewGroup,重点重写下面两个方法 1、onMeasure:测量子view的宽高,设置自己的宽和高 2、onLayout:设置子view的位置 onMeasure:根据子view的布局文件中属性,来为子view设置测量模式和测量值 测量=测量模式+测量值; 测量模式有3种: EXACTLY:表示设置了精确的值,一般当childView设置其宽、高为精确值、match_parent时,ViewGroup会将其设置为EXACTLY; AT_MOST:表示子布局被限制在一个最大值内,一般当childView设置其宽、高为wrap_content时,ViewGroup会将其设置为AT_MOST; UNSPECIFIED:表示子布局想要多大就多大,一般出现在AadapterView的item的heightMode中、ScrollView的childView的heightMode中;此种模式比较少见。 3.LayoutParams ViewGroup LayoutParams :每个 ViewGroup 对应一个 LayoutParams; 即 ViewGroup -> LayoutParams getLayoutParams 不知道转为哪个对应的LayoutParams ,其实很简单,就是如下: 子View.getLayoutParams 得到的LayoutParams对应的就是 子View所在的父控件的LayoutParams; 例如,LinearLayout 里面的子view.getLayoutParams ->LinearLayout.LayoutParams 所以 咱们的FlowLayout 也需要一个LayoutParams,由于上面的效果图是子View的 margin, 所以应该使用MarginLayoutParams。即FlowLayout->MarginLayoutParams ...

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