我定义了一个drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffffff" />
<size android:width="60dp"
android:height="40dp" />
</shape>
但是如何在layout
定义中使用它呢?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:src="@drawable/ic_title"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
/>
</LinearLayout>
我仍然只看到黑色背景。
编辑:
原来我:
在drawable
xmlns
声明中漏掉了一个。现在这个例子可以在 Gingerbread 设备上运行 :)