简体   繁体   English

将图像添加到具有形状的layerlist项目

[英]adding a image to layerlist item with shape

i have a xml as below i trying to add a image from drawable folder but its not working. 我有一个xml如下我试图从drawable文件夹添加一个图像,但它无法正常工作。

<solid android:color="#FFF"/> this is where i need to add image from drawable folder <solid android:color="#FFF"/>这是我需要从drawable文件夹添加图像的地方

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM