How to center drawableTop and text vertically on the Button in Android?
- by Gaks
I have the Button defined as follows:
<Button
android:drawableTop="@drawable/ico"
android:gravity="center"
android:id="@+id/StartButton2x2"
android:text="@string/Widget2x2StartBtnLabel"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/widgetbtn_bg"
/>
The problem is that 'drawableTop' image is aligned to the top border of the Button view. I would like to center it (together with text label) vertically on the button.
'android:gravity' seems to work only on text label. It does not affect 'drawableTop' positioning.
I was able to center it vertically using 'android:paddingTop' - but that does not seem to be a good idea. I guess it would not work properly on different screen resolution/size.