单击第二个标签时,它应该单独显示第二个标签(第一个应该被删除)。点击贴纸1(黄色)时的当前输出,它在屏幕上显示贴纸1,当点击贴纸2(红色)时,前一个贴纸仍在屏幕上(我不想要)输出必须是贴纸2我有尝试实现一个 for 循环,但它不起作用。
完整的活动源代码
public void addSticker(final Sticker sticker) {
if (sticker == null) {
Log.e(TAG, "Sticker to be added is null!");
return;
}
float offsetX = (getWidth() - sticker.getWidth());
float offsetY = (getHeight() - sticker.getHeight());
sticker.getMatrix().postTranslate(offsetX, offsetY);
float scaleFactor;
if (getWidth() < getHeight()) {
scaleFactor = (float) getWidth() / sticker.getDrawable().getIntrinsicWidth();
}
else {
scaleFactor = (float) getHeight() / sticker.getDrawable().getIntrinsicHeight();
}
sticker.getMatrix().postScale(scaleFactor, scaleFactor, getWidth(), getHeight());
mHandlingSticker = sticker;
mStickers.add(sticker);
invalidate();
}