android - 怎么开启Andorid的硬件加速
高洛峰
高洛峰 2017-04-17 13:15:55
0
2
722

自己的andorid app中设置了

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="tsaarni.nativeeglexample"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21"/>
    <application android:label="@string/app_name" 
         android:icon="@drawable/ic_launcher" 
         android:allowBackup="true" 
         android:hardwareAccelerated="true">
        <activity android:name="NativeEglExample"
                  android:hardwareAccelerated="true"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

在MainActivity.onCreate中,设置也开启了window的硬件加速:

setContentView(R.layout.main);
getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

但是UI中的控件得到的硬件加速的状态为ac为false:

    FrameLayout globalFramelayout = (FrameLayout)findViewById(R.id.my_framelayout);
    boolean ac = globalFramelayout.isHardwareAccelerated(); 

请问:
1. 这样判定ac加速的方式正确吗?
2. 如果正确,为什么没有开启硬件加速功能?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
刘奇

android:hardwareAccelerated="true"

If you have this one, it is usually turned on

大家讲道理

You are right, use android:hardwareAccelerated="true" to enable hardware acceleration. Hard acceleration can be turned on at the Application and Activity levels. The acceleration of the View can only be turned off at the View level. After it is turned on on Application or Activity, it will Enabled by default.
The reason why you fail to get ac as true may be that your device itself does not support hard acceleration, and both the simulator and the real machine may not support it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!