Enable hardware acceleration in Android app, targeting Honeycomb AND prior versions

人盡茶涼 提交于 2019-11-30 06:56:49

问题


To enable hardware acceleration in an Android 3.0+ app I can do this:

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

But the app won't build with that attribute present if I target an OS version pre-11. Is there a way to enable hardware acceleration in an app that targets both Honeycomb and prior, or is hardware acceleration only available for those creating apps that only work on 3.0+?

I had a look for a method on Activity but I don't see one.


回答1:


Try to set build target to the 3.0 version, but set minsdkversion to the oldest version you want to support. It should at least allow you to build, but will not enable HW-acceleration on the older versions.

From the documentation:

Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries.

Have not tested the 3.0 API yet myself, but the documentation seems to say this should be supported...

<manifest ... >
    <uses-sdk android:minSdkVersion="4" 
          android:targetSdkVersion="11" />
    <application ... >
    ...
    <application>
</manifest>

(cut from Optimizing Apps for Android 3.0




回答2:


You can leave the min/targetSdkVersion as-is in your manifest. I have mine at 3 & 8. What you need to do is change the SDK you're compiling against. In Eclipse, go to Project Properties > Android and choose a Project API Target with an API Level of 11 or above (e.g., "Android 3.0").



来源:https://stackoverflow.com/questions/5158824/enable-hardware-acceleration-in-android-app-targeting-honeycomb-and-prior-versi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!