Reputation: 4453
I've implemented custom views for EditText as you can see in below image:
Now this custom view includes feature of flipping, editing, rotating, drag & drop and resizing. I'm saving this custom view in bitmap format in explorer. The problem is I want to edit it and I want to restore the detail of the custom view and retrieve each and every detail of the CustomView even the position of it. So, is there any way how to implement it?
Upvotes: 4
Views: 1762
Reputation: 4453
Finally, after searching for few days I got a solution for this.
There is a library named StickerView which helps to store the data of particular Drawable Sticker or any Text Sticker by using Matrix
and many details can be stored by using The object of StickerView
and can be customised by the requirements of an application.
There is one more library similar to this StickerView.
Upvotes: 0
Reputation: 3830
The simplest way of doing it
Upvotes: 1
Reputation: 5721
You need to store all editing like :
Rotation
: for this you have to maintain angle from initial value 0 to next rotation value.
Flip
: create one flag for this , and set True , false value for front and back.
Text
: you know how take text form EditText
.
Layout position within parent View
:
for calculating layout postion within parent View use below method and create four int variable for this ,
Left
=
Top
=
Right
=
Bottom
=
Height
=
Width
=
private Map<String,Integer> getPositionOnScreen(View view){
Map<String,Integer> map = new HashMap<String,Integer>();
View rootLayout = view.getRootView().findViewById(android.R.id.content);
int[] viewLocation = new int[2];
view.getLocationOnScreen(viewLocation);
int[] rootLocation = new int[2];
rootLayout.getLocationOnScreen(rootLocation);
int relativeLeft = viewLocation[0] - rootLocation[0];
int relativeTop = viewLocation[1] - rootLocation[1];
int height = viewLocation[0] - rootLocation[0];
int width = viewLocation[1] - rootLocation[1];
map.put("left",relativeLeft);
map.put("top",relativeTop);
map.put("height",view.getLayoutParams().height);
map.put("width",view.getLayoutParams().width);
return map;
}
Above method return left and top position of view , but you need to calculate right and bottom position from left , top and height , width .
Create one Pojo to hold all this parameters together and store this pojo into SharedPreferences or Data Base or in Application Context.
Upvotes: 4