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

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!)

Related

Physics type animations for floating bubbles

I am currently prototyping making a screen with bubbles (circular xml drawables for now) that have a start and end position and animate in a floating bubble fashion.
I am currently using the new Motion Layout provided in the Constraint Layout alpha build and right now it is both proving a pain to adjust the values (eagerly awaiting the timeline animation tool) or never looking correct.
Is anyone aware of a library that has similar functionality or is Motion Layout the best bet?
Whenever i look for bubble stuff it is regarding the ripple effect on buttons etc and so it's proving a little tough to find anything.
I would ideally like to be able to add bubbles dynamically with a start and end point and then start animations independently but just getting the animations looking right is the main goal right now.
As aside question - does anyone know the official/expected release date for Constraint Layout 2?
Appreciate any pointers.

Scrolling home screen in LibGdx

I am using LibGdx to develop a game. For Now I am not using scene2D. I am struck up in increasing the levels of the game as I do not have the scrolling screen.
I like to design a a scrolling screen as it is in many games which are level based (for ref, lets say Candy crush). Could you please point me a example on how to have such a scrolling screen to show a bigger area where I can show many levels.
Thanks is Advance !
Using the Scene2D function is not necessary for this and is more for GUI implementation and different screens. The Scroll pane really shines when creating reading content that does not fit your phone. I do advice to start learning Scene2D to create MenuScreens and UI though.
What Candy Crush "simply" does is having multiple backgrounds that are placed next to each other and tile seamlessly. They use buttons in the correct place for levels. By dragging a finger across the screen the camera will move in that direction. For the movement from one level to the next there is probably something like a spline in play.
It is important only to draw the background tiles and buttons that are actually visible on the screen if you have many. Since these have fixed positions and you know your camera area and position you can calculate what to draw and what not. Just drawing everything each frame is likely to slow down your fps.
You can do a search on:
Tilemaps, for you backgrounds but you probably want them in just one direction so a simple 1D array would suffice.
Dragging, to move your camera. Here I gave a basic explanations on how I do it.
Splines, are a bit tougher and you do not really need them. They could be used to animate or move something along a curve.
Thats all, expecting you know how to create something like a button (click a sprite).

Alternatives to large horizontally scrolling views in Android

I am writing a DAW-style app and need to implement the side-scrolling timeline common in such programs. In other words it should appear to the user as though they are scrolling through a very large bitmap, several of them actually for the different tracks, seamlessly. Obviously I will have memory issues if I do it with a single very large horizontally-scrolling View, but that needs to be the effect the user sees. Right now I have a custom View for each track and drawing the wave into its Canvas.
I have thought of constructing three Views, left, active and right, and simply swapping out new data when the left or right one is scrolled to in time to be ready for the next screenfull. I think something along these lines is going to be the final solution, but I am not sure what would be the best way to implement it. Should I run a service in the background that watches for and updates the offscreen views, would that be the best way to accomplish this? I haven't used services before. Or is there a more direct way of doing it, attaching some code to the view to execute automatically?
Any suggestions would be appreciated.

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!

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

Categories

Resources