我无法在 api 级别 15 进行硬件加速

I can't hardware acceleration at api level 15

我正在测试在 android 加速的简单硬件。

我在互联网上找到了这段代码,所以我想测试一下。当我在 API 级别 26 测试此代码时它有效,但是当我在相同 avd 的 API 级别 15 测试此代码时,它不起作用。

这是我的清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.shin.myapplication">

<application
    android:hardwareAccelerated="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

和 MainActivity。

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.acceltest1);
    AccelTestView vw = new AccelTestView(this);
    setContentView(vw);
}

这是 AccelTestView 代码

public class AccelTestView extends View {

public AccelTestView(Context context) {
    super(context);
}

public void onDraw(Canvas canvas) {
    Log.v("temp", String.valueOf(canvas.isHardwareAccelerated()));
    invalidate();
}

Here is API Level 15 Image

And here is API Level 26 Image

这两张图片是相同的代码和相同的 avd,即 Nexus 5x。

为什么会这样??

请阅读:

https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported

从图表中可以看出,setAntiAlias 的硬件加速在 API 16 行和 API 18 文本之前不可用。