自己的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. 如果正确,为什么没有开启硬件加速功能?
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.