【发布时间】:2014-01-08 17:14:55
【问题描述】:
如何为形状添加背景图片?我在下面尝试但没有成功的代码:
<?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>
【问题讨论】:
-
您需要扩展并创建一个自定义形状的类。以 RoundedImageView 为例。它会创建一个圆形图像视图,因此无论您设置什么 iamge 作为它的背景,它都会显示为圆形
标签: android android-xml