用于显示图形(节点和边,二维)的 Android 组件?

发布于 2024-11-08 11:40:25 字数 411 浏览 0 评论 0原文

我正处于开发一个类似于“思维导图”程序(如Thinking Space)的Android应用程序的起点。它显示了一些图形节点(包含文本,可能是图像)和连接它们的边。我可以处理图形算法,但是对于用于显示这些内容的 Android 组件,我有两个不确定点:

  1. 展开的图形将非常大,因此用户需要能够垂直和水平滚动。我查看了 ScrollView 和 Horizo​​ntalScrollView 但它们无法垂直和水平滚动。所以我希望知道我应该使用哪个顶级容器。

  2. 我还希望图表可以通过捏合手势进行缩放,以便用户可以放大图表的一小部分。但我还希望图形节点是交互式的,以便用户可以点击它们,在其中输入文本并用手指移动它们。我应该将每个节点实现为单独的 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:

  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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬 2024-11-15 11:40:25

我肯定会依赖自定义视图来完成此类事情,它们会给您比使用标准布局更多的自由度和效率。

实现可滚动视图非常简单,而实现捏合手势则要困难得多如果您支持 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!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文