如何一起使用形状与绘制的图像? [英] How to use a shape drawable together with an image?
问题描述
我有这样的困难,同时拥有圆角和背景图像我的的LinearLayout
。
I have this difficulty to have both rounded corner and a background image in my LinearLayout
.
我知道我可以通过使用形状绘制XML achive圆角,但是如果我把形状绘制作为我的的LinearLayout
的背景机器人:背景= @绘制/ rounded_corner
然后,我不能将任何图片作为背景
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.
我怎样才能既圆角与我的LinearLayout背景图像? 任何帮助将是AP preciated。谢谢!
How can I get both a rounded corner with a background image in my LinearLayout? Any help would be appreciated. Thanks!
推荐答案
您可以使用<一个href="http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList">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.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/rounded_corners" android:id="@+id/rounded_corners"/>
<item android:drawable="@drawable/additional_image" android:id="@+id/additional_image" />
</layer-list>
这篇关于如何一起使用形状与绘制的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!