将图像添加到具有形状的图层列表项 [英] adding a image to layerlist item with shape
本文介绍了将图像添加到具有形状的图层列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个如下所示的xml,我试图从可绘制文件夹中添加图像,但是它不起作用.
i have a xml as below i trying to add a image from drawable folder but its not working.
<solid android:color="#FFF"/>
这是我需要从可绘制文件夹中添加图像的地方
<solid android:color="#FFF"/>
this is where i need to add image from drawable folder
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFF"/>
<stroke android:width="1dip" android:color="#225786" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
还有其他方法可以添加图层列表项吗?这是我尝试过的方法
is there any other way that i can add i tried with layer list with item this is how i have tried
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/background">
<shape>
<solid/>
<stroke android:width="1dip" android:color="#225786" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
</layer-list>
现在它不显示边框,而我只在边框上添加背景.
Now its not displaying the border which i am doing with shape it only adds a background to it.
推荐答案
如果您想要带有边框的背景,请尝试以下操作:
If your want a background with border, try this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/background" />
<item
<shape>
<solid/>
<stroke android:width="1dip" android:color="#225786" />
<corners android:radius="10dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
</layer-list>
如果您只想要背景,请尝试以下方法:
and if your just want a background, try this one:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/background"
android:tileMode="repeat" >
</bitmap>
这篇关于将图像添加到具有形状的图层列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文