创建具有重复模式的 9 补丁
我坚持为进度条背景创建九个补丁。 它有一个像标尺一样的重复模式,这让我头疼。
这是我想要的(底部)和我拥有的(顶部)的图像。
有人能给我一个提示如何实现我的目标吗?
编辑:或者通常可以使用 9patch 来做到这一点吗? 我的另一个尝试是使用 android:tileMode="repeat" 进行 a ,但是我遇到了图像高度的问题(在第二行重复),我需要像 Repeat-x 这样的东西。
提前致谢
edit2:好的,我设法通过拉伸整个重复模式来完成我的重复 9patch,但它并不理想:(
iam stuck with the creation of a nine patch for a progressbar background.
It has a repeating pattern like a ruler-scala and that given me headache.
here is a image of what i want(at the bottom) and what i have (top).
can someone give me a hint how to acomplish my goal?
edit: or is it generelly possible to do this with a 9patch?
my other attempt was to make a with android:tileMode="repeat" but there i get problems with the height of my image (repeating in the second line), i need something like repeat-x.
Thanks in advance
edit2: ok i managed to do my repeating 9patch by stretching the whole repeating pattern, but its not ideal :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎高估了 9 补丁的威力。您最多能做的就是拥有一个标尺图像,其刻度之间的空间不断扩大。但是,您无法制作自动平铺图像部分的 9 块。
另一方面,如果您以编程方式创建 BitmapDrawable,则可以设置平铺模式 X 轴和 Y 轴分别。
You seem to be overestimating the power of 9-patches. The most you could do is have a ruler image with expanding space between the ticks. You can't, however, make a 9-patch that automatically tiles parts of your image.
On the other hand, if you create a BitmapDrawable programatically, you can set the tile mode separately for the X and Y axes.
我曾经在我的 webview 项目中使用边框图像来执行此操作,它提供了两个选项(重复、拉伸、填充)。
由于 webview 在 android 中有一些它自己的问题(主要是固定元素),我决定在下一个项目中使用更多的 android,并且我发现使用 9Patch 不可能有重复的边框。很尴尬,因为有需要但没有实施。
总之android开发领域让我抓狂,这里一个选项一个那里一个选项是这里常见的事情。
I used to do this in my webview project using border image which provides both options (repeat, stretch, fill).
As webview has kind of it's own problems in android (mostly fixed element) I decided to be more android for the next project and I found out that it's not possible to have the repeated border using 9Patch. It's so awkward as it's needy but not implemented.
In a word android development area makes me crazy, one option here one option there is a usual thing here.