你的动画写出来卡嘛?流畅嘛

如果你想提升动画的性能,那就是用它-hardware layers。

During animations your views may be redrawn each frame. If you use view layers, instead of having to redraw each frame, views render once into an off-screen buffer which can be reused.

In addition, hardware layers are cached on the GPU, which makes certain operations during animation much faster. Simple transformations (translation, rotation, scaling and alpha) can be rendered quickly with layers. Since many animations are just a combination of these transformations, layers can supercharge animation performance.

如何使用:

http://developer.android.com/intl/zh-cn/reference/android/view/View.html#setLayerType(int, android.graphics.Paint)

View.setLayerType().

当你想缓存的时候就调用她:View.setLayerType(View.LAYER_TYPE_HARDWARE, null)

当动画结束,就用它:View.setLayerType(View.LAYER_TYPE_NONE, null).

示例代码:

// Set the layer type to hardware
myView.setLayerType(View.LAYER_TYPE_HARDWARE, null); // Setup the animation
ObjectAnimator animator = ObjectAnimator.ofFloat(myView, View.TRANSLATION_X, 150); // Add a listener that does cleanup
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
myView.setLayerType(View.LAYER_TYPE_NONE, null);
}
}); // Start the animation
animator.start();

  

这地方是出处以及源码呦,http://blog.danlew.net/2015/10/20/using-hardware-layers-to-improve-animation-performance/

Android动画之硬件加速的更多相关文章

  1. Android 4.0的图形硬件加速及绘制技巧

    转:http://zuiniuwang.blog.51cto.com/3709988/721798 从Android 3.0开始,Android 2D的绘制流程就设计为能够更好地支持硬件加速.使用GP ...

  2. CSS动画原理及硬件加速

    一.图层 图层即层叠上下文,具体概念和应用大家可以看我之前转自张鑫旭大神博客的<CSS层叠上下文和层叠顺序>,这里我们简单复习一下产生层叠上下文的原因. 1.根层叠上下文 指的是页面根元素 ...

  3. 硬件加速 Hardware Accelerated 绘制

    官方文档中对硬件加速的描述 原文地址:http://developer.android.com/guide/topics/graphics/hardware-accel.html Beginning ...

  4. 通过硬件层提高Android动画的性能

    曾有许多人问我为什么在他们开发的应用中,动画的性能表现都很差.对于这类问题,我往往会问他们:你们有尝试过在硬件层解决动画的性能问题么? 我们都知道,在播放动画的过程中View在每一帧动画的显示时重绘自 ...

  5. Android--hardwareAccelerated 硬件加速详解 android:largeHeap="true"

    做项目时,引导页面的ViewPager报了OOM异常,图片并不大,在清单文件Application节点中添加了两行代码就解决了这个问题 android:hardwareAccelerated=&quo ...

  6. Minimit Anima – 硬件加速的 CSS3 动画插件

    Minimit Anima 是一个实现 CSS3 Transforms 和 Transitions 动画的 jQuery 插件.基于硬件加速的 CSS3 动画执行更快,而且它有一个类似于 jQuery ...

  7. Android硬件加速

    Android从3.0(API Level 11)开始,在绘制View的时候支持硬件加速,充分利用GPU的特性,使得绘制更加平滑,但是会多消耗一些内存. 开启或关闭硬件加速: 由于硬件加速自身并非完美 ...

  8. javascript 手势(swipeLeft,swipeRight)滑动中使用css3动画卡顿,开启硬件加速

    今天,在做一个移动端项目,遇到了css3动画卡顿的现象. 例图: 在手势滑动中(swipeLeft,swipeRight)遇到了动画卡顿的现象,最后使用了css3动画-webkit-transform ...

  9. 119、 android:hardwareAccelerated="true"or"false"硬件加速的重要性

    每次做项目都会遇见一些特别简单的问题,但是又很费时间来让你解决的问题. 1.本身想实现一个简单的画廊效果,可是每次图片的显示都不能显示在正中的位置,真的很烦人,也花费了很长时间.最终还是知道了原因.解 ...

随机推荐

  1. Unique Binary Search Trees,Unique Binary Search Trees II

    Unique Binary Search Trees Total Accepted: 69271 Total Submissions: 191174 Difficulty: Medium Given  ...

  2. I - Long Distance Racing(第二季水)

    Description Bessie is training for her next race by running on a path that includes hills so that sh ...

  3. linux学习笔记之sudo

    引用A:http://blog.chinaunix.net/uid-15811445-id-149961.html 引用B:http://os.51cto.com/art/201307/404879. ...

  4. 如何查找ORACLE中的跟踪文件

    一.跟踪文件是干什么用的?        跟踪文件中包含了大量而详细的诊断和调试信息.通过对跟踪文件的解读和分析,我们可以定位问题.分析问题和解决问题.从跟踪文件的产生的来源来看,跟踪文件又可以分为两 ...

  5. yii中使用active record进行关联显示

    model中: view中:

  6. SQL Server 中索引的禁用与删除

    主题 1. 禁用索引 alter index index_name on table_name disable; 主题 2. 删除索引 drop index table_name.index_name ...

  7. createDocumentFragment

    http://www.cnblogs.com/myjavascript/p/3708920.html 对于循环批量操作页面的DOM有很大帮助!利用文档碎片处理,然后一次性append,并且使用原生的j ...

  8. [置顶] lvs-tun隧道模式搭建

    一.lvs直接路由原理 由于图片还要一张一张上传,可以到下面网站下载我的word版本: http://download.csdn.net/user/y0908105023 补充基础知识: OSI(Op ...

  9. SQL中如何使用UPDATE语句进行联表更新(转)

    在本例中: 我们要用表member中的name,age字段数据去更新user中的同字段名的数据,条件是当user 中的id字段值与member中的id字段值相等时进行更新. SQL Server语法: ...

  10. source insight 下看不了utf-8中文字符

    utf-8中文在source insight中显示为乱码,写了一个简单脚本,在linux下将代码转换为GBK格式,然后在source insight下正常查看. #!/bin/sh function ...