1

On clicking 2nd sticker it should display the second sticker alone (the first one should be removed). current output when clicking in sticker 1(yellow),it display sticker 1 on screen and when sticker 2 (red) is clicked the previous sticker is still on the screen(which i do not want) The output must be sticker 2 alone I have tried implementing a for loop but it does not work. Full Activity source code Figure 1 is the current output,fig 2 and 3 are expected output for 1st and 2nd clicks respectively

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();
}
  • Can you provide more details about the current behaviour nad how is wrong. Also some more comments in the code to understand what is actually going on? – Kuzeko Feb 21 '20 at 10:01
  • added code and details plz check – Christina kriz Feb 21 '20 at 12:47
  • can u please help? – Christina kriz Feb 23 '20 at 03:31
  • I don't see the problem in your method. I believe the problem is that you modify the `canvas` and never restore it to what was before adding the sticker. Also : in this method you do not "remove" the previous sticker. So this method is not the problem. – Kuzeko Feb 23 '20 at 10:08

0 Answers0