如何使用可自定义的拇指制作圆形 SeekBar? [英] How to make a Circular SeekBar with a customizable thumb?
问题描述
我正在使用 Android Studio,我需要一个这样的组件:
I'm using Android Studio and I need to have a component like this:
这些功能很重要:- 接受渐变颜色的progressDrawable;- 我可以作为组件获取的拇指,以便制作动画或在其上方放置文本(如图像中所示);- 我可以自定义图像的拇指,而不仅仅是颜色;- ProgressBar/SeekBar 必须是圆形.- 我希望能够为动画目的以编程方式设置进度;
Those features are important: - progressDrawable that accepts gradient colors; - thumb that I can get as a component in order to animate or to put texts above it (like in the image); - thumb that I can customize with images, not just colors; - the ProgressBar/SeekBar must have a circular shape. - I want to be able to set the progress programmatically for animation purposes;
我对此进行了研究,只能接近我想要的结果,但这还不够.通过使用 Sliders,我可以根据需要自定义拇指,但我无法像在 ProgressBar 中那样控制背景来一点一点地设置它.通过使用 SeekBars 或 ProgressBars,我需要在自定义拇指或使组件循环之间进行选择.
I've made researches about it and I could only get close to the result that I wanted, but it's not enough. By using Sliders, I could customize the thumb as I wanted, but I don't have control over the background to set it bit by bit as in a ProgressBar. By using SeekBars or ProgressBars I need to choose between customize the thumb or making the component circular.
有什么办法吗?
或者至少,如果我可以使用常规的 Circular SeekBar,我会很满意,但可以访问拇指的位置,以便我可以用我选择的组件替换它.
Or at least, I would be satisfied if I could use a regular Circular SeekBar, but having access to the position of the thumb so I could replace it with a component of my choice.
感谢关注!
推荐答案
有什么办法吗?
嗯,总有很多方法可以做到!
Well, There's always many ways to do it!
有很多库可以为你做这件事,所以没有必要重新发明轮子,但在你的情况下,我认为你可能必须发明你的自定义 轮子 因为您正在寻找的所有选项并不在一个库中,但是这些可能会让您感到高兴!: SeekArc , CircularSeekBar 和 CircularSeekBar.
There are lots of libraries that do it for you, so there is no need to re-invent the wheel, but in your case I think you probably must invent your custom wheel because all the options you're looking for is not in a library together, However these may make you happy! : SeekArc , CircularSeekBar and CircularSeekBar.
但是如果它们不能满足您的需求,您可以简单地分叉并将您的自定义选项添加到它们中.也许你应该看看 RoundedBitmapDrawable如果您想将圆形位图添加到 SeekBar
和 RadialGradient 如果你想使用渐变颜色.
But if they didn't satisfy your needs, you can simply fork and add your custom options to them. Maybe you should take a look at RoundedBitmapDrawable in case you want to add a circular bitmap to the SeekBar
and RadialGradient if you want use gradient color for it.
如果您需要有关自己创建自定义 View
的教程,这可以提供帮助:在 Android 中创建自定义和复合视图 - 教程
If you need a tutorial for creating a custom View
on your own this can help: Creating custom and compound views in Android - Tutorial
祝你好运
这篇关于如何使用可自定义的拇指制作圆形 SeekBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!