ShapeDrawable 中的偏移形状
我正在尝试使用扩展 ShapeDrawable 的类来绘制一个带有边框的圆角矩形(请参阅 here)并且一切正常,除了 shapedrawable 似乎正在切断一些边界,因为形状本身不会延伸到这些边界之外。
是否没有某种方法可以偏移 shapedrawable 开始绘制的位置,以便形状本身和画布的边界之间有一些填充?我已经尝试将 ShapeDrawable.setBounds 和 ShapeDrawable.setPadding 都设置为大于形状的固有大小,但似乎没有任何进展。我应该子类化Drawable吗?
I'm trying to draw a rounded rectangle with a border around it using a class that extends ShapeDrawable (see here) and everything is working except that the shapedrawable seems to be cutting off some of the border because the shape itself doesn't extend outside those bounds.
Is there not some way to offset where the shapedrawable starts drawing so that there is some padding between the bounds of the shape itself and the canvas? I have tried both ShapeDrawable.setBounds to larger than the intrinsic size of the shape and ShapeDrawable.setPadding but don't seem to be getting anywhere. Should I be subclassing Drawable instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 inset (inset_shape.xml) 包裹您的形状可绘制:
然后根据需要使用 inset_shape 。
You can wrap you shape drawable with inset (inset_shape.xml):
Then just use the inset_shape as you need.
在你的绘图中尝试这个......!
Try this in your drawable...!