开发者

Circular / rotary dial view in android

开发者 https://www.devze.com 2023-04-10 10:50 出处:网络
I have a need to create a circular dial/rota开发者_如何学运维ry style component for use in an application. It\'s essentially a circular menu that allows users to select from the items that are ringed

I have a need to create a circular dial/rota开发者_如何学运维ry 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!


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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号