详细:http://developer.android.com/intl/zh-cn/guide/topics/graphics/hardware-accel.html

Application level

In your Android manifest file, add the following attribute to the <application> tag to enable hardware acceleration for your entire application:

<application android:hardwareAccelerated="true" ...>

Activity level

If your application does not behave properly with hardware acceleration turned on globally, you can control it for individual activities as well. To enable or disable hardware acceleration at the activity level, you can use theandroid:hardwareAccelerated attribute for the <activity> element. The following example enables hardware acceleration for the entire application but disables it for one activity:

<application android:hardwareAccelerated="true"><activity ... /><activity android:hardwareAccelerated="false" />
</application>

Window level

If you need even more fine-grained control, you can enable hardware acceleration for a given window with the following code:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

Note: You currently cannot disable hardware acceleration at the window level.

View level

You can disable hardware acceleration for an individual view at runtime with the following code:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Note: You currently cannot enable hardware acceleration at the view level. View layers have other functions besides disabling hardware acceleration. See View layers for more information about their uses.

Determining if a View is Hardware Accelerated


It is sometimes useful for an application to know whether it is currently hardware accelerated, especially for things such as custom views. This is particularly useful if your application does a lot of custom drawing and not all operations are properly supported by the new rendering pipeline.

There are two different ways to check whether the application is hardware accelerated:

  • View.isHardwareAccelerated() returns true if the View is attached to a hardware accelerated window.
  • Canvas.isHardwareAccelerated() returns true if the Canvas is hardware accelerated

If you must do this check in your drawing code, use Canvas.isHardwareAccelerated() instead ofView.isHardwareAccelerated() when possible. When a view is attached to a hardware accelerated window, it can still be drawn using a non-hardware accelerated Canvas. This happens, for instance, when drawing a view into a bitmap for caching purposes.

Android 代码强制启动GPU渲染相关推荐

  1. 开启xmp1还是2_玩机鸭x:手机开启“强制进行GPU渲染”功能对手机有什么影响?...

    安卓手机从4.0版本开始,开发人员在选项中加设了"强制进行GPU渲染"功能.那么开启强制进行GPU渲染功能有什么样的好处.或者什么样的坏处呢? GPU对于手机的作用是什么? 手机中 ...

  2. android7 强制gpu渲染,安卓手机开启强制GPU渲染功能的方法

    安卓手机怎么开启强制GPU渲染功能?安卓手机是目前市场占有率最多的智能手机系统,但是当用户使用搭载有安卓系统的手机后,我们就会发现随着使用时间的增加,手机速度就会变得越来越慢,其实这是安卓系统手机的通 ...

  3. colab清理gpu缓存_安卓手机为什么会变卡?强制GPU渲染手机就能变流畅?你真的懂吗...

    使用过安卓手机的朋友都知道,安卓手机最大的毛病就是卡顿,那你知道安卓手机变卡的原因吗?还有网上很多教程说开启"强制进行GPU渲染"手机就会变流畅,真的是这样吗? 我们先来了解安卓手 ...

  4. 安卓手机为什么会变卡?强制GPU渲染手机就能变流畅?你真的懂吗

    使用过安卓手机的朋友都知道,安卓手机最大的毛病就是卡顿,那你知道安卓手机变卡的原因吗?还有网上很多教程说开启"强制进行GPU渲染"手机就会变流畅,真的是这样吗? 我们先来了解安卓手 ...

  5. 使用 GPU 渲染元素 问题

    使用 GPU 渲染元素 并不是所有的CSS属性都能触发GPU的硬件加速,实际上只有少数属性可以,比如下面的这些: transform opacity filter 强制使用GPU渲染 为了避免 2D ...

  6. Android硬件加速(二)-RenderThread与OpenGL GPU渲染

    Android4.0之后,系统默认开启硬件加速来渲染视图,之前,理解Android硬件加速的小白文简单的讲述了硬件加速的简单模型,不过主要针对前半阶段,并没怎么说是如何使用OpenGL.GPU处理数据 ...

  7. 【Android 性能优化】布局渲染优化 ( 过渡绘制 | 自定义控件过渡绘制 | 布局文件层次深 | GPU 过渡绘制调试工具 | 背景过度绘制 )

    文章目录 一. 过度绘制 二. 过度绘制两种情况 ( 自定义控件 | 布局文件 ) 三. 过度绘制调试 1. 打开过渡绘制调试工具 2. 过渡绘制调试中不同颜色的含义 3. 过渡渲染示例 四. 背景过 ...

  8. 【Android 性能优化】布局渲染优化 ( GPU 过度绘制优化总结 | CPU 渲染过程 | Layout Inspector 工具 | View Tree 分析 | 布局组件层级分析 )

    文章目录 一. GPU 过度绘制优化总结 二. CPU 渲染过程 三. CPU 渲染性能调试工具 Layout Inspector 四. Layout Inspector 组件树 DecorView ...

  9. Android App性能分析工具(一)——GPU渲染分析

    我尽量不打错别字,用词准确,不造成阅读障碍. 一.GPU渲染速度 该工具在"开发者选项"里面,是用来展示应用每一帧中渲染消耗的时间及内容. 1.图中每一个竖条就是一帧,不同颜色代表 ...

最新文章

  1. xshell添加脚本
  2. dtm文件生成等高线 lisp_DEM、DSM和DTM的区别
  3. BZOJ1565[NOI2009]植物大战僵尸——最大权闭合子图+拓扑排序
  4. 聊一聊基于Nacos的metadata完成服务间的AB测试
  5. 解析PHP跳出循环的方法以及continue、break、exit的区别介绍
  6. oracle--逻辑对象--bai
  7. 华为年底开源其操作系统 EulerOS,更名为 openEuler
  8. github 思维导图开元软件_Windows上有哪些很棒思维导图的软件
  9. jQuery中的gt和lt
  10. ASP.NET学生考勤管理系统【源码分享】
  11. Linux命令之iconv命令
  12. 鼎利5G测试软件不显示信息,鼎利软件应用 - 4G/5G - 通信人家园 - Powered by C114
  13. python除数为0报错_Python3报错-Python入门到精通
  14. 图解Sysprep封装系统
  15. 资本运作/自我投资--哪项需要优先?
  16. 短址服务实现的一些算法
  17. flink设置checkpoint部署后一直重启,出现检查点无法写入的问题
  18. python 监听键盘输入并收集数据进行分析
  19. prometheus定义counter指标
  20. python读取文件名或路径含中文字符的图片并从中筛选出全白或者全黑的图片

热门文章

  1. Android Listview 自定义BaseAdapter的实现及Listview优化示例
  2. 批量转换json到java bean工具说明
  3. VulnHub—HA-Avengers Arsenal
  4. 【网络爬虫】爬取豆瓣电影Top250评论
  5. vue制作可拖动的div(超级简单)
  6. android 静默重启 QUIESCENT REBOOT
  7. vsco怎么两个滤镜叠加_抖音VSCO调色怎么弄 抖音超火滤镜教程详细设置流程
  8. python里chars_python的string.strip(s[, chars])方法的各种小细节
  9. Tomcat服务的下载和安装
  10. 【板栗糖GIS】怎么在CAD中进行连续标注