Place imageviews along a curved path - android

I am trying to develop a custom gallery like application in which, i would like to place Image views along an elliptical path whose size varies with position.
All ideas are welcomed.
Thanks & Regards,
Sen

I have only two ideas:
create a path, do the math and position the ImageViews inside a RelativeLayout/AbsoluteLayout on the calculated position. So you only use the path to do the math, not to really position the views on that
Use 2D drawing (on a canvas) there you can draw images along a path... how to draw a bitmap repeatedly on a path can be seen here: http://www.mail-archive.com/android-developers#googlegroups.com/msg14567.html

Related

Android canvas: Is it possible to add images from gallery?

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.

How to create custom view with rounded border in Android

Hi,
I'm trying to understand how to make custom view (with green background) on Android like represented on attached image. Please suggest, should I use Path for this or something else?
A good starting point would be http://tips.androidhive.info/2013/09/android-layout-rounded-corner-border/ . Then you can play with the attribute values to get the desired background. Hope this helps.
You have two good options for accomplishing this.
Bitmap
Create the desired image in Photoshop, Gimp or something similar. Export it as a png file then import it as a bitmap resource into your Android application.
This is by far the simpler and faster of the two methods, but here are two significant problems. First, you should supply bitmaps for each screen density bucket. Second, each bitmap resource you add increases the install size of your app. This can get out of hand quickly.
Path
As you mentioned in your question, you can draw the desired shape directly onto a canvas using a Path. More specifically, you'll use the cubicTo() method to create bezier curves.
I recommend using your image editor's "path" tool to learn how the control points affect the curve. Once you've drawn the shape in the image editor, write down the coordinates for every point on your path as well as the corresponding control points. Then do a little math to convert the points to ratios of the image's overall width and height.
You can implement the shape in your app as a View or as a Drawable. In either case, you'll be drawing to a Canvas. The important step will be to set up the path by multiplying the ratios with the size of your drawing area. After you draw the fancy edge, be sure to draw the straight edges via lineTo() and to close the shape with close().

Android: What to use for rendering the layers of photo-editor?

Hello friends!
I need to create a photo editor, which allow to put the emoticons, text and drawing with a brush on the picture.
Open the illustration
An editor must be able to change the position of smiles & text, their size and rotation with two fingers (multi-touch).
Mechanics is clear to me. I found ready realization of multi-controller:
https://github.com/lukehutch/android-multitouch-controller
But I don't understand how better visualize all the layers in terms of performance:
Layer 3 - text
Layer 2 - emoticons
Layer 1 - drawing
Layer 0 - photo
I am afraid to use the canvas, without your opinion. I heard that the canvas buggy when displaying a large number of images.
I found examples visualize the layers of images using layer-list with the 's inside. I think this method will be more performance numbers for my task.
But I have not found documentation of how to update the position (top / left) when you move an item.
My question is: What is the best use for the visualization of all layers and the possibility to save the final image (merge all layers)?
Please help, what to choose and what is the right path!
Thank you in advance! :)
Canvas is not buggy. It's the only way for you to render things onto a Bitmap. By the looks of your requirement, I think you need to draw your Layers onto different bitmaps. Layer 0 will be your default bitmap. Every other layer will be individual bitmaps on their own. The reason they have to be on a bitmap of their own is so that you can move them as you wish.
You final merge will be to draw all these bitmaps, on the default bitmap via Canvas.drawBitmap() call.

Moving the image in canvas in user defined path

I need to move the image in the canvas. The image should not follow a linear or circle or elliptical path. I know this can be achieved by using the COS and SIN functions. But here I need to get the image traversed in a 4 different path like I have shown in the below snapshot. Please help me if there is anyway to achieve this. It should be fine even If I get any idea to achieve this .
snapshot:
I'd try the android animation package first - you should be able to define a few points and get this to smooth the path between the points.
See here: http://developer.android.com/guide/topics/graphics/view-animation.html

How to draw paths of decreasing width in android canvas?

I wanted to draw path effect in android canvas like, the path should give the actual feel like a brush. The path should not start or end with linear width. While starting, width should be increasing linearly up to given width and while ending the reverse, width should be decreasing. It would be helpful if we can do the same for the opacity of the line. The path effect should be as following.
Is there any direct way to do it in android? Please let me know.
Thank you.
Maybe a better way to go about accomplishing this would be to render a (filled) polygon instead? Create a new path using moveTo lineTo lineTo, etc to define your brush stroke. Once completed and closed, fill the triangle with the appropriate command. Android also supports passing your vertices and colors in an array using the drawVertices method. Good luck~!

Categories

Resources