Tuesday 1 October 2013

How can i make my square button and spinner the same height?

How can i make my square button and spinner the same height?

usecase:
I want a spinner with a clickable, squared image-button to the right of
it, on the same row, with the button the same height as the spinner.
There was first a problem getting an imagebutton to be square, which i
solved reading this thread: How do I keep the aspect ratio on image
buttons in android?
I now have them on the same row and with the icon square and resized, but
not quite to the size of the spinner, the 9-patch (i think) of the spinner
creates some sort of padding around it and my image uses that to set its
height, so that it looks like this:
If someone can help me out here it would be greatly appreciated.
Layout-xml below:
<LinearLayout android:layout_weight="1" android:id="@+id/spinnerRow"
android:orientation="horizontal"
style="@style/horizontalLayout" android:gravity="top"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:paddingTop="5dp">
<LinearLayout android:id="@+id/spinLayout"
style="@style/spinLayout" android:layout_weight="1">
<Spinner android:id="@+id/locSelect"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:prompt="@string/loc_prompt"></Spinner>
</LinearLayout>
<com.karpet.nuba.util.SquareButton
android:id="@+id/info" android:orientation="horizontal"
android:gravity="top" android:layout_height="fill_parent"
android:layout_width="wrap_content" android:layout_weight="0.5">
<ImageView
android:id="@+id/info"
android:src="@drawable/info"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</com.karpet.nuba.util.SquareButton>
</LinearLayout>

No comments:

Post a Comment