DrawableView
DrawableView copied to clipboard
Ability to center canvas on w/h of the view
The following values will be allowed:
drawableView.setGravity(Gravity.CENTER_HORIZONTAL);
drawableView.setGravity(Gravity.CENTER_VERTICAL);
drawableView.setGravity(Gravity.LEFT);
drawableView.setGravity(Gravity.RIGHT);
drawableView.setGravity(Gravity.TOP);
drawableView.setGravity(Gravity.BOTTOM);
Or combinations like drawableView.setGravity(Gravity.LEFT | Gravity.BOTTOM);
You really need to address Canvas issues and set proper methods for a seamless experience. I don't want to pull out my hair trying to calculate statusbar height and actionbar height and instruct the canvas to start from the top and subtr......
please :)
@Odaym what issues are you talking about?
Finding it impossible to set canvasHeight to the exact with and height of the image that is loaded under it. So that you could only draw within certain bounds. Not posting code because its too much effort now, I'd rather keep trying it.
By the way also config.setShowCanvasBounds never seemed to show any bounds while the bounds were there
and this issue that you mentioned above is just what I need to fix what I just mentioned, because I start off with the drawableView centerInParent and then I set the canvas and I see it starts from the top left as a view that has just been added newly, maybe your config is overriding it and setting to 0, 0 instead of the original position that was set in XML.
Also, try declaring the drawableView in XML with wrap on both width and height, set its background color to white to see it, it takes match parent on both, fills up the whole screen (without adding a config that contains canvas height and width)
Sorry I am urinating over this comments section. I was wrong about setShowCanvasBounds being shown, they are being shown it's just that the color of the bounds is black... I am still trying things, I just understood that the canvas of this drawableview is being placed on the view at 0,0 when its config is added, that's my problem
6421-6421/com.om.atomic D/SIZE﹕ numbers used to set dimens on drawableView and canvas size H 2000 W : 2000
06-03 03:31:40.937 6421-6421/com.om.atomic D/SIZE﹕ Dimens after setting it on canvas : H 2000 W : 2000
06-03 03:31:40.937 6421-6421/com.om.atomic D/SIZE﹕ Dinens after setting it on drawableView : H 2000 W : 2000
same number set for the actual width and height of the drawableView, then setting the canvas of that drawableView to be the same number (so that the canvas would be the exact size of the drawableView) (both of these numbers come from the bitmap that I've loaded initially that I want to now draw over with a drawableView)
When the above happens, the canvas takes a much larger size than the 2000, 2000 and leads to being able to scroll through it because it's that large, so when it comes to obtainBitmap() from the drawableview of course it will fuck up the position of where I drew on it because it was much larger than the image that I want to stick it on
I checked the code and you are using createBitmap when you want to obtainBitmap() of course, and using pixels as measurement. But there is something that you do inside the CanvasDrawer class you have this strange line 32 where you scale the canvas by the scaleFactor:
canvas.scale(scaleFactor, scaleFactor);
So I am trying to figure out how to account for that number when setting the canvas dimensions to be the same as the drawableview, because that's needed in my case to get an accurate picture of both