cannot set height and width of a resource shape in styles
I recently made my first custom shape and it turned out really good accept one thing. i can't seem to set the height and with of the drawable resource in a style resource.
I do not specify a height or width in på shape because i want to use this shape in different sizes. So i set height and width in my styles.xml file. But the final result is what looks like the shape using wrap_content as both height and width which i do not want.
Any help is greatly appreciated!
SHAPE - list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid
android:color="@color/list_item_background"
/>
</shape>
</item>
<item>
<shape android:shape="rectangle" >
<gradient
android:angle="270"
android:startColor="@color/list_item_gradient_white"
android:endColor="@color/list_item_gradient_black"
android:type="linear"
/>
<stroke
android:color="@color/list_item_stroke"
android:width="1px"
/>
</shape>
</item>
STYLE
<style name="SmallListItem">
<item name="android:background">@drawable/list_item</item>
<item name="android:layout_height">69.5dip</item>
<item name="android:layout_width">fill_parent</item&开发者_如何学编程gt;
</style>
Try something like this:
<ImageView
style="@style/SmallListItem"
android:src="@drawable/list_item" />
See http://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList for more information on how to use your layer-list
精彩评论