StickerView icon indicating copy to clipboard operation
StickerView copied to clipboard

how to set an Sticker in specific position in view

Open HoussemHfaidh opened this issue 6 years ago • 5 comments

Hello , i want to save the last position of Sticker , and when i reload an app i want to set the Sticker on last position do you have an idea ?

HoussemHfaidh avatar Aug 14 '17 12:08 HoussemHfaidh

@HoussemHfaidh i use for this Matrix

abbath0767 avatar Sep 19 '17 07:09 abbath0767

If it helps, I wait until after the sticker is added, in a StickerView.OnStickerOperationListener, and then adjust its matrix:

@Override public void onStickerAdded(@NonNull Sticker sticker) {
    // you provide desired_w, desired_h, desired_left, desired_top
    sticker.setMatrix(freshInsetMatrix(desired_w, desired_h, desired_left, desired_top));
  }

  private Matrix freshInsetMatrix() {
    float sticker_w = inset_sticker.getWidth();
    float sticker_h = inset_sticker.getHeight();

    float scale_x = desired_w / sticker_w;
    float scale_y = desired_h / sticker_h;

    Matrix matrix = new Matrix();
    matrix.postTranslate(desired_x / scale_x, desired_y / scale_y);
    matrix.postScale(scale_x, scale_y);
    return matrix;
  }

instantiator avatar Sep 20 '17 09:09 instantiator

Hi, thank you for your support :)

2017-09-20 10:44 GMT+01:00 instantiator [email protected]:

If it helps, I wait until after the sticker is added, in a StickerView. OnStickerOperationListener, and then adjust its matrix:

@Override public void onStickerAdded(@NonNull Sticker sticker) { // you provide desired_w, desired_h, desired_left, desired_top sticker.setMatrix(freshInsetMatrix(desired_w, desired_h, desired_left, desired_top)); }

private Matrix freshInsetMatrix() { float sticker_w = inset_sticker.getWidth(); float sticker_h = inset_sticker.getHeight();

float scale_x = desired_w / sticker_w;
float scale_y = desired_h / sticker_h;

Matrix matrix = new Matrix();
matrix.postTranslate(desired_x / scale_x, desired_y / scale_y);
matrix.postScale(scale_x, scale_y);
return matrix;

}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wuapnjie/StickerView/issues/58#issuecomment-330801676, or mute the thread https://github.com/notifications/unsubscribe-auth/ASXm7KmGgT74c_brvXYCawG-CGwH_dgrks5skN54gaJpZM4O2U9l .

--

*Cordialement * Houssem Hfaidh Web & Mobile Developper Tel : 00216 20 26 94 16

HoussemHfaidh avatar Sep 21 '17 07:09 HoussemHfaidh

@instantiator how can i place sticker below another sticker?

chnouman avatar Nov 19 '17 08:11 chnouman

@instantiator it works for me but for diff devise position is little changed how can i fixed it for all devise

shahparshva avatar Aug 21 '18 16:08 shahparshva