如何将可绘制的形状与图像一起使用?
我在 LinearLayout
中很难同时拥有圆角和背景图像。
我知道我可以通过使用形状可绘制 XML 来实现圆角,但是如果我使用 android:background=@drawable/rounded_corner
LinearLayout 的背景> 那么我无法指定任何图像用作背景。
如何在 LinearLayout 中获得带有背景图像的圆角? 任何帮助将不胜感激。谢谢!
I have this difficulty to have both rounded corner and a background image in my LinearLayout
.
I know I can achive the rounded corner by using the shape drawable XML, but if I put the shape drawable as the background of my LinearLayout
with android:background=@drawable/rounded_corner
then I cannot assign any image to be used as a background.
How can I get both a rounded corner with a background image in my LinearLayout?
Any help would be appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 LayerDrawable,它可以包含尽可能多的图层(形状或图像)根据您的需要。您可以将其创建为资源或以编程方式创建。
You could use LayerDrawable, which could contain as many layers(shapes or images) as you need. You can create it either as resource or programmatically.
寻求不同答案的人
xml 中
对于那些在 oncreate 或 General
作为函数的
for those who seeks a different answer
in the xml
in the oncreate or general
as a function