Issue
Is it valid for a drawable shape in Android to use fill_parent
for it's size?
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="#666666"/>
<size
android:width="fill_parent"
android:height="fill_parent"/>
</shape>
EDIT
This for the background of ImageButton
views. I want the icon for the button to have a circle behind it, but I don't always know what the size of the button will be (different sizes per layout).
Solution
Not really. Not using a ShapeDrawable
alone. If you go through the ShapeDrawable
document, you will see (you are already using them in the tag) that the only valid attributes there are px, dp, sp, in and mm
A quote from the doc: android:width="...."
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters) This is true for the attribute:
android:height
This is speculation on my part, but I suspect why the fill_parent attribute value will not work is because a ShapeDrawble
, unlike an XML Layout
file will not have a parent container.
Leaving out the <size.... />
attribute entirely and setting the layout_width
and layout_height
on a Widget that will reference the said ShapeDrawable is the only option I suspect (if the fill_parent
is to be honored).
Answered By - Siddharth Lele
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.