Gir*_*iya 11 android canvas android-9.0-pie
下面Canvas没有在android 28中找到的变量.
canvas.saveLayer(0, 0, getWidth(), getHeight(), null,
Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
Run Code Online (Sandbox Code Playgroud)
Che*_*amp 16
这些标志已在API 28中删除.请参见此处:
类android.graphics.Canvas
删除方法int save(int)
删除字段int CLIP_SAVE_FLAG
int CLIP_TO_LAYER_SAVE_FLAG
int FULL_COLOR_LAYER_SAVE_FLAG
int HAS_ALPHA_LAYER_SAVE_FLAG
int MATRIX_SAVE_FLAG
该方法在API 26中已弃用.请参见此处:
此方法在API级别26中已弃用.请改用saveLayer(float,float,float,float,Paint).
用什么代替
根据CanvasAPI 28 的源代码,您使用的标志组合起来等于以下值ALL_SAVE_FLAG:
public static final int ALL_SAVE_FLAG = 0x1F;
public static final int MATRIX_SAVE_FLAG = 0x01;
public static final int CLIP_SAVE_FLAG = 0x02;
public static final int HAS_ALPHA_LAYER_SAVE_FLAG = 0x04;
public static final int FULL_COLOR_LAYER_SAVE_FLAG = 0x08;
public static final int CLIP_TO_LAYER_SAVE_FLAG = 0x10;
Run Code Online (Sandbox Code Playgroud)
从相同的源代码调用 Canvas#saveLayer(left, top, right, bottom, paint)默认为使用ALL_SAVE_FLAG:
/**
* Convenience for {@link #saveLayer(RectF, Paint)} that takes the four float coordinates of the
* bounds rectangle. */
public int saveLayer(float left, float top, float right, float bottom, @Nullable Paint paint) {
return saveLayer(left, top, right, bottom, paint, ALL_SAVE_FLAG);
}
Run Code Online (Sandbox Code Playgroud)
因此,看起来您的代码等同于以下代码,您可以将其用作替换:
canvas.saveLayer(0, 0, getWidth(), getHeight(), null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6388 次 |
| 最近记录: |