微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在xml Android中添加背景图片以形状

如何将背景图片添加到形状?代码我试过下面但没有成功:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
//here is where i need to set the image
<solid android:color="@drawable/button_image"/>
    <corners
     android:bottomrighTradius="5dp"
     android:bottomLefTradius="5dp"
     android:topLefTradius="5dp"
     android:topRighTradius="5dp"/>
 </shape>

提前致谢。

使用以下图层列表:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/image_name_here" />
    <item>
        <shape android:shape="rectangle" android:padding="10dp">
            <corners
                 android:bottomrighTradius="5dp"
                 android:bottomLefTradius="5dp"
                 android:topLefTradius="5dp"
                 android:topRighTradius="5dp"/>
         </shape>
   </item>

</layer-list>

原文地址:https://www.jb51.cc/xml/293969.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。