是否可以改变android搜索栏的形状?
我想实现类似于 android 搜索栏的东西。但不是以线性方式,而是以弧形。是否可以将搜索栏定制为弧形?
I want to implement something similar to android seek bar.But not in a linear fashion,in an arc shape. is it possible to customize the seek bar in an arc shape?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了水平偏移之外,您不能让 SeekBar 以任何其他方式绘制拇指。
实际绘制拇指的代码位于 AbsSeekBar.onDraw 中,可以看到它只是水平偏移。
但是,您可以创建自己的小部件来扩展 ProgressBar,它将以任何需要的方式(以弧形)绘制拇指。但您还需要对触摸做出响应,将其转换为 ProgressBar 期望的线性范围。
You can't make SeekBar to draw its thumb any other way than offset horizontally.
The code that actually draws thumb is in AbsSeekBar.onDraw, and there it's seen it's just horizontal offset.
You may however make your own widget extending ProgressBar, which would draw thumb whatever way is needed (in arc). But you'll also need to make response to touches to translate it to linear range that ProgressBar expects.
您可以在自己的主题中更改搜索栏的样式(请查看 android:style/Widget.SeekBar),但可能很难使其像彩虹一样。
尝试阅读 ProgressBar 的源代码并根据您的要求编写自己的基础。
You can change the style of seekbar in your own themes, (have a look at android:style/Widget.SeekBar), but it could be hard to make it like a rainbow.
Try to read the source code of ProgressBar and write your own base on your requirements.
我认为您也许能够使用像 LevelList 这样的 XML 可绘制对象来实现效果,尽管您可能需要大量图像才能实现效果 http://developer.android.com/guide/topics/resources/drawable-resource.html#LevelList
I thought you might be able to achieve the effect with an XML drawable like the LevelList, though you would probably have to have lots of images to achieve the effect http://developer.android.com/guide/topics/resources/drawable-resource.html#LevelList