I want to put a photo in Android app that you can touch it in some parts and can edit it with an EditText, Check Box, etc.
You should look into the Canvas class as a basis for this. You can draw bitmaps, text, and perform image manipulations on the Canvas.
CanvasView is a nice simple API that builds on Canvas allowing you to draw/erase and add text/images onto a Canvas easily.
Related
I'm working with some data I've captured with an external sensor and I have it as a bitmap. I want to draw some annotations over it and then save it to a file. Is there a native Android way to do this? Like some standard 2D graphic calls? I just want to draw text and some lines. All the examples I have found use canvas or focus on doing it in the view, and I know how to do it in a view. But this is kind of behind the scenes, I just want to draw and save in my own image saving class. I thought for a minute I had it with Graphics, but I couldn't get that to work in Android.
Thank you
In some paint apps or note taking apps, they will allow you to add text and images in addition to drawing stuff.
Now I know that I can create a custom view and override on touch events and build paths and draw them on canvas.
But what I don't know is this: In apps like mentioned above I am confused if they add images as image views or they add images directly drawn on canvas.
I mean do they create new imageview and set the gallery image to it, or they simply add the image directly to the canvas.
Any thoughts?
Thanks.
They draw it directly to the Canvas. Notice the Canvas class (which is how Views draw) has a drawBitmap and drawText functions. Generally in a drawing app the entire area you draw on will be just 1 view.
I'm developing an android app in which I want to integrate a feature using which user can take screenshot, doodle something on it and then send it via mail.
How to implement this? I just need a pen for doodling and an eraser to erase last doodle.
Take a look at this library :
ActiveDoodle
You can display two ImageViews on top of each other: the bottom one containing the photo, the top one containing an initially transparent Bitmap. In the top ImageView's onTouchEvent() method you can transform touch events into strokes of pen applied to the bitmap using a Canvas. You might want to read up on MotionEvents and Canvases.
After the user is done with doodling, you can load the screenshot to a Bitmap, rescale the doodle bitmap to match the screenshot's size, and draw in on top, again using a Canvas. Reading about Porter/Duff algebra will probably prove useful with applying an XferMode to a Paint.
I'm writing a app for a tablet. I have a activity that contains text and buttons and an area where I want to put something that is drawn on a canvas. When buttons are pressed I want to draw a grid that will contain lines, text and images, built dynamically.
What I can't figure out is after I draw this on the canvas how to put/embed the canvas into the activity in a certain area(ImageView?). I have a prototype app where I can draw the grid, but I can't figure out how to put the canvas into the activity.
Any help or point me to an article would be really appreciated. Thanks
First you get a bitmap from your canvas then you can use it in your ImageView via ImageView.setImageBitmap(mCanvasBitmap)
I am trying to implement the drag and drop functionality in Android. I have a Custom View that overrides the onDraw(Canvas canvas) method to draw a Bitmap on a canvas that acts as my background. Then, I have created it so I can select different colors and paint in this area.
Now, I am trying to add the ability to select photos from the gallery and place them into the canvas. Also, I want to add the ability to create and add textboxes to the canvas area as well. How would I implement this?
I have read through several tutorials looking to create multiple views that are placed in a Canvas, but have not found an example of this being one. Am I understanding the Canvas and View classes incorrectly and is there a simpler way to do this? Any help is very much appreciated. Thank you.