2 番目のステッカーをクリックすると、2 番目のステッカーだけが表示されます (最初のステッカーは削除されます)。ステッカー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();
}