Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  1. 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.

  2. 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.

like image 984
Ian Avatar asked May 20 '11 11:05

Ian


1 Answers

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

like image 162
bigstones Avatar answered Oct 21 '22 03:10

bigstones