Hardware Acceleration硬件加速

关于绘制GifView异常:


09-22 16:09:50.769 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.779 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.779 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.779 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.789 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.789 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.789 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.799 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.799 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.example.xxx.gifview.MainActivity.access$super
'android.view.SearchEvent', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.809 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.xxx.gifview.MainActivity.access$super
09-22 16:09:50.859 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
09-22 16:09:50.889 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.view.ViewOutlineProvider', referenced from method com.example.xxx.gifview.view.GifView.access$super
09-22 16:09:50.889 10394-10394/com.example.xxx.gifview E/dalvikvm: Could not find class 'android.animation.StateListAnimator', referenced from method 

我的处理方式是:

public GifView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);resources = context.getResources();//android 4.0硬件加if (Build.VERSION.SDK_INT >=       Build.VERSION_CODES.HONEYCOMB) {setLayerType(View.LAYER_TYPE_SOFTWARE, null);}// 从描述文件中读出gif的值,创建出Movie实例TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView);int resourceId = array.getResourceId(R.styleable.GifView_src, -1);setGifResource(resourceId);array.recycle();}
  1. Beginning in Android 3.0 (API level 11), the Android 2D rendering pipeline is designed to better support hardware acceleration. Hardware acceleration carries out all drawing operations that are performed on a View’s canvas using the GPU. Because of the increased resources required to enable hardware acceleration, your app will consume more RAM.
根据官网翻译可得:从Android 3.0(API级别11)开始,Android 2 d渲染管道是为了更好地支持硬件加速。硬件加速进行的所有绘图操作上执行一个视图使用GPU的画布。因为增加的资源需要启用硬件加速,你的应用将会消耗更多的内存。
The easiest way to enable hardware acceleration is to turn it on globally for your entire application. If your application uses only standard views and Drawables, turning it on globally should not cause any adverse drawing effects. However, because hardware acceleration is not supported for all of the 2D drawing operations, turning it on might affect some of your applications that use custom views or drawing calls. Problems usually manifest themselves as invisible elements, exceptions, or wrongly rendered pixels. To remedy this, Android gives you the option to enable or disable hardware acceleration at the following levels:- Application- Activity- Window- View> 启用硬件加速的最简单方法是将全局整个应用程序。如果您的应用程序只使用标准视图和画板,把它在全局范围内不应造成任何不良影响。然而,由于不支持硬件加速的2D 绘图操作,将其在可能会影响你的一些使用自定义视图或绘制调用的应用程序。问题通常表现为无形的元素、异常或错误地显示像素。为了补救,Android给你选择启用或禁用硬件加速在以下级别:1.Application2. Activity3. Window4. View----------
Controlling Hardware Acceleration

Application level

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

应用程序级别
在你的Android清单文件中,添加以下属性的<应用>标记为您的整个应用程序启用硬件加速:
<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 the android:hardwareAccelerated attribute for the element. The following example enables hardware acceleration for the entire application but disables it for one activity:

`

如果您的应用程序不正确的行为和硬件加速全球打开,你可以控制它对个人Activity。启用或禁用硬件加速在活动级别,您可以使用android:hardwareAccelerated 元素的属性。下面的例子启用硬件加速整个应用程序,但禁用这一活动:

<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);

View level

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

你可以禁用硬件加速单个视图在运行时使用以下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
{setLayerType(View.LAYER_TYPE_SOFTWARE, null);       }

在android studio开发中,关于绘制GifView异常,硬件加速问题的解决办法相关推荐

  1. 关于Android Studio开发中“unfortunately, xxx has stopped”的错误提示

    在Android Studio开发中,可能会遇到这样的情况:代码提示中没有任何的错误信息,但在运行虚拟机.点击某个按键进行操作时,可能会出现"unfortunately, xxx has s ...

  2. Android Studio之debug调试卡在waiting for debugger界面的解决办法

    1.问题 Android Studio debug调试项目卡在waiting for debugger界面 2.解决办法 一开始从启adb服务 adb stop-server adb start-se ...

  3. android studio 新建工程慢,关于AndroidStudio新建与编译项目速度慢解决办法

    android第一次新建项目是,相关依赖包需要下载很久,至少半小时,因为网速问题,还会多次下载失败. 解决办法如下: 1.通过镜像将gradle-5.4.1-all.zip下载到本地:解压到文件夹:D ...

  4. Visual studio 2017中 Javascript对于Xrm对象模型没有智能提示的解决办法

    Visual studio 2017中 Javascript对于Xrm对象模型没有智能提示的解决办法 先上个图.语法提示支持到 Microsoft Dynamics xRM API 8.2 也就是cr ...

  5. Android开发:Android studio开发中引用图片资源(图解)

    在使用Android studio开发程序时,是一定要接触怎么引用图片资源的,但是由于eclipse和Android studio 对于图片文件的引用存在差异,所以致使很多刚接触Android stu ...

  6. android studio安装中出现Failed to install Intel HAXM错误的解决方法

    1.问题分析 从下面可以知道安装Intel HAXM失败,请检查haxm_silent_run.log这篇日志. (1)先了解一下什么是Intel HAXM Intel代表的是英特尔,HAXM的全程是 ...

  7. Android Studio模拟器运行出现VT-x提示,无法打开模拟器的解决办法

    之前公司的台式机在打开Android Studio自带的模拟器的时候出现了一个问题:vt-x is disabled in BIOS,为此我还专门到网上查询了一下,原来是系统BIOS中支持模拟器运行的 ...

  8. java enumerator_java 中遍历取值异常(Hashtable Enumerator)解决办法

    java 中遍历取值异常(Hashtable Enumerator)解决办法 用迭代器取值时抛出的异常:java.util.NoSuchElementException: Hashtable Enum ...

  9. Android studio 开发中 用git实现批量忽略特定文件的方法

    git实现批量忽略特定文件的方法 在用AndroidStudio开发项目的时候,3个人协同开发,那么用Git同步代码,会将模块中的大量iml文件同步,每次都会提交和更新,一个一个的去忽略他们,显然是最 ...

  10. android studio 一直refreshing,AndroidStudio更新出现Refreshing 'xxx' Gradle Project状态解决办法...

    前言 开发项目之前,我用的是AndroidStuio2.1.0版本,项目开发完后,按耐不住就更新编译环境了.编译环境更新至AndroidStuio2.2.2. 更新完后,激动的打开AndroidStu ...

最新文章

  1. java常用弹出式对话框
  2. link 和 @import 的区别
  3. EF批量插入太慢?那是你的姿势不对
  4. 简单句(Simple sentences)-one
  5. Deployment vs ReplicationController in Kubernetes
  6. dreamweaver半角空格_在Dreamweaver MX中,中文输入时要输入空格应该()。A.在编辑窗口直接输入一个半角空格B.代码中输入...
  7. 广度(宽度)优先搜索学习笔记
  8. jmeter聚合报告详解
  9. 流传甚少的seo排名爆破技术全解析
  10. vue点击按钮切换样式
  11. 日常工作记录---在虚拟机中进行slam建图
  12. Python报错:ValueError: operands could not be broadcast together with shapes
  13. 大数据可视化陈为智慧树_知到智慧树大数据可视化网课答案
  14. 计算机组成原理实验五:CPU组成与机器指令执行实验
  15. GO+MySQL,如虎添翼!
  16. MySQL创建数据表的三种方式
  17. ecshop 2.7.2安装
  18. jvm垃圾回收之垃圾收集器
  19. WINDOWS键盘事件监控原理及应用 (转)
  20. 成都边锋 云端虚拟化工具 系统驱动层 原理初窥

热门文章

  1. dotnet C# 全局 Windows 鼠标钩子
  2. 幅值与峰峰值的计算_正弦波的幅度指的是峰值还是峰峰值
  3. python编写的bt爬虫实践
  4. 如果命运是一条孤独的河流,谁会是你的灵魂摆渡人
  5. 语音增强二,麦克风阵列
  6. 【Unity3D插件】Dialogue System for Unity插件分享《对话系统插件》
  7. java正则表达式详解
  8. 软件开发团队中各个成员的英文简称
  9. linux下qt程序以管理员运行,如何让QT程序以管理员权限运行(UAC)
  10. 潮流计算和最优潮流计算