用于显示图形(节点和边,二维)的 Android 组件?
我正处于开发一个类似于“思维导图”程序(如Thinking Space)的Android应用程序的起点。它显示了一些图形节点(包含文本,可能是图像)和连接它们的边。我可以处理图形算法,但是对于用于显示这些内容的 Android 组件,我有两个不确定点:
展开的图形将非常大,因此用户需要能够垂直和水平滚动。我查看了 ScrollView 和 HorizontalScrollView 但它们无法垂直和水平滚动。所以我希望知道我应该使用哪个顶级容器。
我还希望图表可以通过捏合手势进行缩放,以便用户可以放大图表的一小部分。但我还希望图形节点是交互式的,以便用户可以点击它们,在其中输入文本并用手指移动它们。我应该将每个节点实现为单独的 View 对象吗?如果是这样,如何使所有节点一起缩放?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我肯定会依赖自定义视图来完成此类事情,它们会给您比使用标准布局更多的自由度和效率。
实现可滚动视图非常简单,而实现捏合手势则要困难得多如果您支持 API >= 8,则更容易(请参阅
ScaleGestureDetector
)。不过,使图形元素具有交互性和可编辑性则是另一回事。更好的事情可能是创建一个自定义布局,它将托管可编辑的图形元素(自定义视图)并绘制它们的关系。它将更加优雅、干净、可扩展、可维护和可重用,但需要更多的设计。但我确信这会得到巨大的回报。
(这对我来说是一个非常雄心勃勃的项目,所以......祝你好运!)
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!)