How to create infinite scrollable and zoomable view android? - android

I am very new to android programming, and I want to create a large infinite scrolling and zoomable activity where I can add views much like the empty activity we get in the Simple Mind app. Which layout and activity type should I use? What we the best way to implement this? Any help or pointers to tutorials are welcome.

No view in Android is infinite, you're going to run out of memory at some point. The solution you choose will depend on how interactive you need the zoomed view to be.
You can check out android pinch zoom for previous discussions on this topic.
If you're just looking at displaying information and not editing then I'd suggest custom tile maps for google maps.
https://developers.google.com/maps/documentation/android/tileoverlay
I've seen it used before for very high resolution viewing of paintings.

Related

What is the best approach for drawing and animating images on Android

Im experienced iOS dev but new to Android dev and asking some newbie questions here...
I have to make a app where I have a background image and I then place some other images on top of that, and also onto those images I have to place different "glow" images that flicker (opacity on/off), and I need good control on positioning all those images. Now there is not some high performance goal here, and its not many objects, its not really a game.
What is the best approach for this? Can I use ImageView's for this or will it be better to use a Surface and custom draw in a thread?
And please, what ever you suggest, can you give a link to a good tutorial on the approach (ImageView or custom draw), I need all the help I can on this project with its crazy deadline.
Thank you
Søren
In my experience:
if its mostly static you should stick to XML and stuff like ImageViews etc
if its simple animations, the predefined android classes are fine and somewhat easy to use
if you want real custom then drawing with canvas is the way to go
You can extend View and override the onDraw method or create a SurfaceView which has better performance but is not that easy to use.
(sorry i dont have any tutorial links)

How to implement a zoom in/out effect on GridView in Android

When creating images and texts it is very common to develop a zoom in/out feature in UI, as it haves many applications mainly related to accessibility. In my situation, I'd like to create a customized type of view similar to a gridview, but with the difference that the data is not scrolled but transpassed in front/back directions, so in my case, it is more related to user-experience than accessibility. In this video the described "behavior" is better resumed/defined. I want to create a gridview with this effect, where the previous items can be bring from the "out-screen" to screen and the next items can be bring from the "deep-screen" to the screen, and the gridview itself is static in relation to scrolls. Is it possible? Currently, I'm taking efforts to create it all from scratch using onScrollStateChanged and default zoom implementations through size-scale the data (which is a very harsh solution).
Thanks in advance!

Best approach to develop a GPS like application

I'm new to android and I'm starting to develop a GPS like application for android, the basic concept of the app is to show up a blueprint, and display on top of it pins with information related to the position on the blueprint and other settings.
An example of this would be taking a blueprint of an apartment which you can scale and pan, and on top of it place markers with information about each part of the apartment and obviously positioned in the right places like bathrooms, bedrooms, kitchen, etc.
My question is what is the best approach to develop this kind of functionality?
My first thoughts were to use a RelativeLayout as a container, an ImageView for the blueprint with zoom and pan capabilities and individual views for the pinning with the respective place for information positioned based on the zoom and pan of the image.
Then I kept digging and saw the 2d Graphics option but I don't really know how to implemented for this.
I'll appreciate if anyone can send me in the right direction and if is possible some examples as well.
Thank you in advance.
Use a MapView with an ItemizedOverlay to display the markers. Here's a step-by-step answer how to accomplish this (See Item B of the answer).

set the origin (x,y) of a view inside of a RelativeLayout

I have some game pawns on a screen inside of a RelativeLayout. When the user clicks the pawn I would like then to be able to drag it under there finger. I have the MotionEvent captured but can't seem to find how to adjust the orion of the pawn.
I've seen posts saying to adjust the margin but that seems questionable. I still want to do hit tests for the pawns after they've been moved and don't understand how to work with the margins in that case.
thanks!
I would recommend not using a Relative Layout at all.
A Canvas is a much better option
Or if you really want to use a layout, possibly an AbsoluteLayout is a better option
Using a layout for a game may prove unsatisfactory as you proceed. I can recommend using the free and open source game engine AndeEngine for making 2D games. The problems you have with collision detection and x,y positioning are trivially easy to implement with it. I've made 2 games and a visualization view within an app with is so far.
Check it out here:http://www.andengine.org/
You can download the demo app to your android device and see its out-of-the-box capabilities. (They include Sprites, sound, animation and more.)
This one game I made with it.
https://market.android.com/details?id=com.plonzogame&hl=en

Android components for displaying a graph (nodes and edges, in 2D)?

I'm at the starting point of developing an android app similar to a "mindmap" program (like Thinking Space). It shows some graph nodes (containing text, maybe images) and edges that connecting them. I can take care of graph algorithms, but I have two uncertain points about Android components for displaying these things:
The expanded graph will be pretty big, so the user need to be able to scroll both vertically and horizontally. I looked at ScrollView and HorizontalScrollView but they can't scroll both vertically and horizontally. So I hope to know which top level container I should use.
I also want the graph to be zoomable with pinch gestures, so that the user can zoom in to a small part of the graph. But I also want the graph nodes to be interactive, so the user can tap on them, typing text into them and move them with fingers. Should I implement each node as a separate View object? If so, how do I make all the nodes zoom together?
Thanks.
I would definitely rely on custom views for this kind of things, they will give you much more freedom and efficiency than using standard layouts.
Implementing a scrollable view is quite easy, and implementing the pinch gesture will be much easier if you're supporting API >= 8 (see ScaleGestureDetector). Making graph elements interactive and editable would be another thing, though.
Something really much better could be creating a custom layout, that would host editable graph elements (custom views) and draw their relations. It would be much more elegant, clean, expandable, maintainable and reusable, but it would need a lot more designing. Yet I'm sure it would be greatly rewarded.
(This would be quite an ambitious project for me, so... good luck!)

Categories

Resources