我有一个 ImageView 子类,它应该在显示图像的下角显示一个徽标。我有这个 onDraw 代码来在图像顶部绘制图标。它在 ICS+ 上运行良好,但没有更低。有谁知道这是什么原因?
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int canvasHeight = canvas.getHeight();
int canvasWidth = canvas.getWidth();
Drawable icon = getResources().getDrawable(R.id.icon);
int width = icon.getIntrinsicWidth();
int height = iconcon.getIntrinsicHeight();
int x = canvasWidth - width - PADDING;
int y = canvasHeight - height - PADDING;
icon.setBounds(x, y, canvasWidth - PADDING, canvasHeight - PADDING);
icon.draw(canvas);
}