-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't access stickers at position which is saved like rotated,resized #14
Comments
You need to save the matrix and save that and while resuming back you have to redraw them so they are on the last saved location |
did you find a solution for this? |
Yes I have saved the StickerView Matrix, Bitmap as uri, and from matrix i can retrieve the coordinates and re position again on resume or on new activity wherever i want. |
@pravindodia how to save matrix? |
when you save the object to get the matrix from the Sticker view like StickerView.getmatrix().getvalues. If you need a sample code, just let me know. |
i have saved StickerPropertyModel . and use code like that: -- public void setBitmap(Bitmap bitmap, StickerPropertyModel model) but my problem is unable to set saved bitmap to saved matrix position . |
@Ram8948 To Save the Parameters needed. for which i modified the StickerView for (View item : mViews) { ViewStateModel viewStateModel = new ViewStateModel(); viewStateModel.setmValues(getMatrixValues(((StickerView) item).getMatrix())); viewStateModel.setViewStateId(((StickerView) item).getStickerId()); viewStateModel.setSaved(true); viewStateModel.setStartTime(((StickerView) item).getShowPosition()); viewStateModel.setStopTime(((StickerView) item).getHidePosition()); viewStateModel.setSticker(((StickerView) item).getStickerRes()); mViewState.add(viewStateModel); } Now to restore it back you can do this. for (ViewStateModel item : mViewList) { final StickerView stickerView = new StickerView(this); if (item.isSaved()) { stickerView.getMatrix().setValues(item.getmValues()); stickerView.setId((int) item.getViewStateId()); stickerView.setSaved(item.isSaved()); stickerView.setImageResource(item.getSticker()); } RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); lp.height = (int) newVideoHeight; lp.width = (int) newVideoWidth; lp.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); canvasview.addView(stickerView, lp); //canvasview is contentrootview to which we are going to add the stickers. mViews.add(stickerView); stickerView.setInEdit(false); stickerView.setLockMode(true); } You might have to modify the stickerview to set and get the values you want. let me know if you want to know what is the model i have used. Hope you understand and help you to understand your requirement. Thanks |
Could you explans how to use calculate in StickerView method to get this infor? |
i have saved scaling ,translation ,rotation position from calculate method. now how to restore it back |
@Ram8948 |
i want to save matrix data for long time ,but in future if matrix reference is lost than what i can do? |
Please be a bit brief for some response from other people who want to help. short and general questions are difficult to answer. |
@pravindodia can we add these stickers in scrollview? |
@Kaunain26 you can but it will not not editable in scollview, or even if you make it editable it will not be a good User Experience. |
Actually my requirement is a scroll view. I am creating a notes app in which users can add stickers in it. So if the user scrolls the view then I don't think sticker could go down. |
@Kaunain26 it can but you have to handle that in parent view and use a separate view for create/edit stickerview and then insert the sticker in parent view with scroll and it will work. |
` I tried to modify it like this , i made parent scrollView and added relativeLayout in that parent . But in this way sticker is not getting added. can u help? |
this modified XML is working fine. I just did opposite of the above give code of mine Is this correct... in this way stickers are coming on the view. |
This is the wrong approach, what I am saying is your sticker will be in scroll view and if you want to edit the sticker then there should be different view which is sticker view |
sorry but i am not getting it. Can you plz give me a code example if you are free. |
Sorry For what I am telling I cannot give you a sample code As you said you are creating a notes app
so not both can have scroll view in it. Main View (Any Layout you want) When you want to edit the sticker view from not edit view, That's it. |
@pravindodia Thank you so much for your quick replies, whatever you are saying i understood and I achieved 50% of my requirement. But the problem is Sticker view is not able to move properly in Scrollview. It started colliding the view , I mean started scrolling both at the same time when trying to move the sticker. So what i am thinking is it possible to add a one more sticker view which will be outside of this parent nestedScrollview ( this parent nestedScrollView already contains the stickerView.) So user interaction will be with the sticker view which is outside the parent nestedScrollview and when user will move or edit the sticker then same time it update the other sticker view which is inside the parent nestedScrollView. This idea i got from your above comment only. It's little bit different. I don't know it is possible or not. |
hey @pravindodia can you provide the code, that you modified in StickerView to get the values and what model you used. |
@Kaunain26 sorry but I did this project 8 years ago and so I don't have the code. |
(getMatrixValues(((StickerView) item).getMatrix())) can you explain this plz. How you are getting the matrix value. When i am trying to get this sticker.getMatrix() then everytime it's value is same. |
StickerView item is modified to save and get matrix values , its parent class already has that methods which you can override. and you can get and set the values as you require. |
i am saving that stickers page so that i can also retrieve it later and can edit elements to existing one on page like i have saved some rotated stickers on a page but now i want to edit that page like want to change position of that rotated image or can add some more image but problem is that when i open old saved page that is having stickers it is giving me in middle and in proper default form ,not in form i edited in past
The text was updated successfully, but these errors were encountered: