My question is somewhat based off of this question. Displaying SVG files in Android
I have decided to display an SVG in my app, and I do so using the svg-android library. My problem is now how to add pinch to zoom functionality. Maybe this library is outdated and someone knows of another to accomplish this task. From what I see in the javadocs of svg-android, there doesn't seem to be any easy way to add pinch to zoom.
That's not something that needs to necessarily be part of the SVG library. You just need to implement onTouchEvent() in your view and use a ScaleGestureListener etc to keep track of your scales and pans.
http://developer.android.com/training/gestures/scale.html
Related
I am trying to display an image and pinch-zoom into the image. There doesn't seem to be any built in thing for this. I saw that there are some libraries, but would much rather not use a library for this.
Anyone have an idea on how to do this?
You should refer this answer which uses this library. And also refer the library by Chrisbanes. This is the best place for beginner tutorial
Has anybody experience with using svg for creating custom buttons on android? I recently stumbled upon the svg-android project that was used for androidify and I'm wondering whether it is worth the trouble rewriting the code.
At the moment I'm using nine-patch buttons. The only problem is that I need to create several images for different resolutions. However, if I switch to vector graphics, I'm not sure how to preserve the rounded corner radius when I resize the button, for example.
Has anyone experience and can tell me whether it's worth the trouble ?
It sounds like you should maybe use Shapes instead of 9-patches. They superior in most of the cases (especially with rounded corners, gradients ...) : http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
You can also use layer-lists to stack shapes.
The last time I used the svg-android project, it wasn't sufficient for my SVG's due to limitations in its rendering. I don't know what its current state (if different) is, but based on my year-old experience with this on Android, I'd say spend some time to experiment with it before you commit to using it -- perhaps its limitations will not affect you.
For certain picture oriented apps I need to display big pictures and scrollable areas with further detail, once zoomed in.
In saw discussions and examples in iOS using CATiledLayer, which seems to do the job there.
Is there a CATiledLayer "port" or something similar for Android?
This library seems to be very good:
https://github.com/moagrius/TileView
I see you've started your own, but you may wish to check out OSMDroid, which is a full-featured library that supports existing online map tile systems, as well as locally-cached tiles and a rich overlay API. It even supports mini-maps.
I'm new to Android and Java programming and I've manage to create a simple paint program, but how do I add a zoom feature? Right now I'm just extending the View class and using the "onDraw()" method.
Do I have to use a Drawable to be able to add zooming functionality? I'm not really understanding the differences between the two.
If I am way off base then please point me to a good tutorial on paint/zooming.
I think your question is beyond the scope that stackoverflow Q/A format can provide. I know you're asking for 'simple' but imho that's probably due to your lack of perception about the scope of the question that you're asking.
In order to support zooming you need to know what kind of image processing engine you want. Are you creating a vector or raster based drawing program? If you do not understand the difference between the two then you'll going to have a difficult time figuring out what to do.
You should probably at least gain a basic understanding about these various topics (links to books pulled more or less from the top of amazon's search results):
Image Processing
Computer Graphics Fundamentals, two, and three
SVG (vector graphic format)
Wikipedia links:
Vector Graphics
Raster Graphics
Image Processing
Open source image processing apps (not android but source code never hurts to see how others have done something)
Paint.net
GIMP
Inkscape
I'm sorry there isn't an easy and direct answer to your question. I'm also not saying that you need to become an expert in these topics to do what you want. You just need to familiarize yourself with them and then you'll probably be able to implement what you want without much difficulty.
I have a couple of images on available to my program. They are parts of jigsaw puzzle (with rectangular pieces though). I wanted the look and feel similar to that of google maps in android.
One way I could implement was to create a set of ImageViews and keep recycling them, as the user pans the image in any direction. However, to me that appears like a brute force method. Is there any alternative approach to implement such kind of application?
Or rather how is google maps implemented? A set of Imageviews ?
I think for your case the OpenGL route might be the best choice. You can get started with the GLSurfaceView.
Using set of images and recycling them is a valid method. But you can enhance it by adding some redundant ones to keep close to view area images preloaded.