When i change the targetAPI in the manifest from 13 to 14 (or higher) the Picture no longer work. No matter what or how.
当我将清单中的targetAPI从13更改为14(或更高)时,Picture不再有效。无论如何或如何。
Example
例
Paint bluepaint = new Paint();
bluepaint.setColor(Color.BLUE);
Picture pic = new Picture();
Canvas testcanvas = pic.beginRecording(300, 300);
testcanvas.drawColor(Color.BLUE);
pic.endRecording();
canvas.drawColor(Color.RED);
canvas.drawLine(0, 0, 480, 480, bluepaint);
canvas.drawPicture(pic);
This should draw a blue screen from the pic, it does so in API 13 and lower. It does NOT draw the blue but only the red from the pure canvas.draw call.
这应该从图片中绘制一个蓝色屏幕,它在API 13和更低版本中这样做。它不会绘制蓝色,只会绘制纯canvas.draw调用中的红色。
I can't see any change from API 13 to 14 that would explain this.
我无法看到API 13到14的任何变化可以解释这一点。
However i am using cyanogenmod on a Galaxy S2 (so i can run 4.3), not sure if they change native stuff on cyanogen, switched to it couple of weeks ago.
然而,我在Galaxy S2上使用cyanogenmod(所以我可以运行4.3),不确定他们是否会改变氰基上的原生物,几周前改用它。
Any idea where to look for answers or what could cause this ?
知道在哪里寻找答案或可能导致这种情况的原因是什么?
edit
编辑
working
加工
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="13" />
NOT working
不工作
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="14" />
2 个解决方案
#1
0
If targetSdkVersion
is 14 (Ice Cream Sandwich) or higher then hardware acceleration is enabled by default for the whole app. Unfortunately Canvas.drawPicture()
is not supported if hardware acceleration is enabled.
如果targetSdkVersion为14(冰淇淋三明治)或更高,则默认情况下会为整个应用启用硬件加速。不幸的是,如果启用了硬件加速,则不支持Canvas.drawPicture()。
There are two way to fix this:
有两种方法可以解决这个问题:
-
Add
android:hardwareAccelerated="false"
to theapplication
tag in your AndroidManifest.xml. This will disable hardware acceleration for your whole app.将android:hardwareAccelerated =“false”添加到AndroidManifest.xml中的应用程序标记。这将禁用整个应用程序的硬件加速。
-
You can use
Bitmap
andCanvas.drawBitmap()
which is supported with hardware acceleration.您可以使用硬件加速支持的Bitmap和Canvas.drawBitmap()。
Reference: http://developer.android.com/guide/topics/graphics/hardware-accel.html
参考:http://developer.android.com/guide/topics/graphics/hardware-accel.html
#2
-1
Use these dependency ... here 26.0.2 is a bug and Version 14 is not supportable. give these dependency:-
使用这些依赖...这里26.0.2是一个错误,版本14是不可支持的。给出这些依赖: -
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
and Make SDK version:-
并制作SDK版本: -
**
**
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.yeshveer.mygraphics"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"}
**
**
But you can try once with dependency without change SDK version.
但是您可以尝试使用依赖而无需更改SDK版本。
and Remember canvas.restore(); dont use
并记住canvas.restore();不要用
#1
0
If targetSdkVersion
is 14 (Ice Cream Sandwich) or higher then hardware acceleration is enabled by default for the whole app. Unfortunately Canvas.drawPicture()
is not supported if hardware acceleration is enabled.
如果targetSdkVersion为14(冰淇淋三明治)或更高,则默认情况下会为整个应用启用硬件加速。不幸的是,如果启用了硬件加速,则不支持Canvas.drawPicture()。
There are two way to fix this:
有两种方法可以解决这个问题:
-
Add
android:hardwareAccelerated="false"
to theapplication
tag in your AndroidManifest.xml. This will disable hardware acceleration for your whole app.将android:hardwareAccelerated =“false”添加到AndroidManifest.xml中的应用程序标记。这将禁用整个应用程序的硬件加速。
-
You can use
Bitmap
andCanvas.drawBitmap()
which is supported with hardware acceleration.您可以使用硬件加速支持的Bitmap和Canvas.drawBitmap()。
Reference: http://developer.android.com/guide/topics/graphics/hardware-accel.html
参考:http://developer.android.com/guide/topics/graphics/hardware-accel.html
#2
-1
Use these dependency ... here 26.0.2 is a bug and Version 14 is not supportable. give these dependency:-
使用这些依赖...这里26.0.2是一个错误,版本14是不可支持的。给出这些依赖: -
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
and Make SDK version:-
并制作SDK版本: -
**
**
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.yeshveer.mygraphics"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"}
**
**
But you can try once with dependency without change SDK version.
但是您可以尝试使用依赖而无需更改SDK版本。
and Remember canvas.restore(); dont use
并记住canvas.restore();不要用