0
您好形狀,我試圖將其包含在我的佈局中,但它不顯示?Android包含xml形狀
這是我的形狀XML「damage.xml」
<shape xmlns:android="http://schemas.android.com/apk/res/android"
shape="rectangle">
<solid color="#ff0000" />
<stroke width="3dp" color="#ff0000" />
這是我的,我想我需要包括在佈局形狀。
<?xml version="1.0" encoding="utf-8"?>
<View android:id="@+id/damage" android:background="@layout/damage"
android:layout_width="5dip" android:layout_height="wrap_content">
</View>
<ImageView android:id="@+id/icon" android:layout_width="60px"
android:layout_height="60px" android:layout_marginRight="6dip"
android:src="@drawable/placeholder" />
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:padding="6dip">
<TextView android:layout_width="fill_parent" android:id="@+id/title"
android:layout_height="wrap_content" android:text="Item Name"
android:textStyle="bold" android:singleLine="true" android:textSize="16sp" />
<ImageView android:id="@+id/rating" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/rating_five" />
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content" android:id="@+id/range"
android:layout_height="wrap_content" android:text="Range"
android:textStyle="bold" android:singleLine="true" android:textSize="16sp"
android:paddingRight="5dip" />
<TextView android:layout_width="fill_parent" android:id="@+id/condition"
android:layout_height="wrap_content" android:text="Condition"
android:textStyle="bold" android:singleLine="true" android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
但是沒有被抽?我哪裏錯了。其次,在視圖中設置形狀的寬度和heoght是否正確,或者我應該在damage.xml中做到這一點?例如
<shape xmlns:android="http://schemas.android.com/apk/res/android"
shape="rectangle">
<solid color="#ff0000" />
<size android:height="wrap_content" />
<size android:width="5dip" />
<stroke width="3dp" color="#ff0000" />
這裏編譯器抱怨WRAP_CONTENT。
任何幫助將不勝感激。
android:color =「」似乎沒有工作。我也將damage.xml移到了drawable文件夾中。我想要矩形佔據列表行的全部高度,這就是我選擇wrap_content的原因。我還可以使用其他什麼價值? – Bear
如果你想要矩形佔據列表行的全部高度,你應該使用layout_height =「match_parent」。 –
現在很好用:-)非常感謝 – Bear