是否可以将 SeekBar 的拇指图像延伸到栏之外?

发布于 2024-09-06 01:28:07 字数 530 浏览 13 评论 0原文

我在自定义搜索栏上设置了负填充,以便圆形拇指图像可以超出栏外,但拇指不会在那里渲染,是否有办法强制将拇指绘制在这些边界之外?

抱歉,大家,我是 Android 开发新手,我的任务是修复现有的应用程序。问题是我们有一个自定义的圆形轨迹栏,它由两个圆形“端盖”图像和一个平铺以创建搜索栏的 1 像素背景组成。据我所知,从来没有一张图像可以设置为普通 SeekBar 的背景,这就是创建自定义图像的原因。

拇指是一个圆圈,需要“适合”端盖 - 杆的三个部分处于相对布局。现在我有点不清楚 1 px 背景 png 如何像搜索栏 bg 一样拉伸,否则我会尝试以某种方式将两个端盖固定到该可绘制对象上......?

如果不清楚,请告诉我,我会尝试发布任何后续信息。预先感谢您的任何建议!

哦,如果这与任何人的兴趣相关的话,我正在使用 Android 2.1 :)

这就是当拇指完全移到搜索栏之外时的样子。理想情况下,我需要的是拇指显示为端盖图像“内部”:-/

I have set negative paddings on my custom seekbar so that the round thumb image can go outside the bar, but the thumb isn't rendered out there, is there anyway to force the thumb to be drawn outside those bounds?

Sorry guys, I'm new to Android development, and have been tasked with fixing an existing application. The problem is that we have a custom rounded looking track bar, which consists of two rounded 'end cap' images and a 1 px background that is tiled to create the seekbar. As far as I can tell there was never one image that could be set as the background of a normal SeekBar, which is why a custom one was created.

The thumb is a circle and needs to 'fit' into the end caps - the three pieces of the bar are in a relative layout. Right now I'm kind of unclear as to how the 1 px background png gets stretched as the seekbar bg, otherwise I would try to tack on the two endcaps onto that drawable some how ... ?

Please let me know if this was unclear and I'll try to post any followup info. Thanks in advance for any advice!!

Oh, I'm using Android 2.1 if that's relevant to anyone's interests :)

This is what it looks like when the thumb all the way over - outside of the seekbar. Ideally what I need is for the thumb to be shown as 'inside' the endcap image :-/

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

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

发布评论

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

评论(3

帥小哥 2024-09-13 01:28:08

我刚刚遇到这个问题。我通过在 XML 中使用 android:paddingLeftandroid:paddingRight 获得了满意的结果。

I just ran into this issue. I was able to get satisfactory results by using android:paddingLeft and android:paddingRight within the XML.

一曲爱恨情仇 2024-09-13 01:28:07

我也遇到了同样的问题,我的拇指非常长,而且一直被切断。确保在为拇指设置可绘制对象之后设置偏移属性,如下所示:

seek.setThumb(Main.app.getResources().getDrawable(R.drawable.thumb));
seek.setThumbOffset(15);

当拇指很长时,这将设置正确的偏移量。

I was having the same problem, my thumb is very big length wise and it kept being cut off. Make sure that you set the offset property AFTER you set the drawable for your thumb, like this:

seek.setThumb(Main.app.getResources().getDrawable(R.drawable.thumb));
seek.setThumbOffset(15);

This will set the correct offset when your thumb is very long.

烟若柳尘 2024-09-13 01:28:07

尝试更改拇指偏移属性,之后它就不会从搜索栏消失

Try to change the thumb offset property, after that it will not go off from the seek bar

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