Android 中的圆形/旋转表盘视图

发布于 2024-12-07 18:29:59 字数 192 浏览 0 评论 0原文

我需要创建一个圆形表盘/旋转式组件以在应用程序中使用。它本质上是一个圆形菜单,允许用户从周围的项目中进行选择,然后他们可以单击中心的按钮来激活所选项目。但是,我从未创建过这种类型的自定义 UIView,并且真的不知道从哪里开始。谁能告诉我如何绘制视图,然后在用户拖动手指时旋转它?我显然知道如何拦截触摸事件等,但我不确定如何实际适当地操作 UI。任何提示或指示都会很棒!

I have a need to create a circular dial/rotary style component for use in an application. It's essentially a circular menu that allows users to select from the items that are ringed around it, and then they can click the button in the center to activate the selected item. However, I've never created a custom UIView of this type, and don't really know where to begin. Can anyone give me any pointers as to how I would draw the view and then rotate it as the user drags their finger? I obviously know how to intercept touch events, etc. but I'm not sure how to actually go about manipulating the UI appropriately. Any tips or pointers would be great!

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

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

发布评论

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

评论(2

痞味浪人 2024-12-14 18:29:59

我不知道您是否已经找到了解决方案,但这里有一个关于如何开始的很好的概述:

http://shahabhameed.blogspot.com/2011/05/custom-views-in-android.html

对于你来说,我认为你可以扩展现有视图,该视图是 SeekBar。您可以使用标准的 SeekBar 并将其画成一个圆圈。

最后,这是一个使用音量旋钮进行旋转的源代码。但它是它自己的项目,因此您必须做一些工作才能在您自己的应用程序中使用它。

http://mindtherobot.com/blog/534/ android-ui-making-an-analog-rotary-knob/

祝你好运!

I don't know if you've already found a solution to this, but here is a nice overview of how to get started:

http://shahabhameed.blogspot.com/2011/05/custom-views-in-android.html

For you, I think you can extend an existing View, that View being the SeekBar. You can take the standard SeekBar and draw it in a circle.

Finally, here is a source code that does the rotation with a volume knob. It is its own project though, so you have to do some work to use it in your own app.

http://mindtherobot.com/blog/534/android-ui-making-an-analog-rotary-knob/

Good Luck!

佼人 2024-12-14 18:29:59

我有一个整洁的图书馆来做到这一点。它非常稳定并且维护得很好。 https://bitbucket.org/warwick/hgdialrepo
这是 YouTube 演示:https://youtu.be/h_7VxrZ2W-g
该库附带一个带有源代码的演示应用程序,该演示应用程序实际上使用拨号盘作为菜单,所以我认为这应该是您的完美解决方案。

I have a neat library to do this. It is extremely stable and well maintained. https://bitbucket.org/warwick/hgdialrepo
Heres a youtube demo: https://youtu.be/h_7VxrZ2W-g
This library comes with a demo app with source code and the demo app actually uses a dial as a menu, So I think this should be the perfect solution for you.

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