views:

146

answers:

1

Hi

I want to design a TableLayout with some big buttons with icon and text embbeded. I have found some similar question but not the same 1. My simplified XML layout is:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow android:id="@+id/TableRow01" android:gravity="center">
<Button android:text="@string/telephone" android:drawableTop="@drawable/phone" android:id="@+id/button_phone"></Button>
<Button android:text="@string/help" android:src="@drawable/help" android:id="@+id/button_help"></Button>
</TableRow>
</TableLayout>

The icon images are a little big, so I want to Android resizes them but the android:height parameter resizes the button, not the embedded image. Do you any idea to get an Button with Text and Image "resizeable"?

+1  A: 

Use the ScaleType attribute (Documentation)
EDIT: See here for information on supporting multiple screen sizes with your drawables. If you follow the android conventions instead of trying to just use really large drawable and resize them at runtime for smaller screens, you'll have much better perfomance and fewer issues.

QRohlf
Sorry but scaleType attibute applies for ImageButton, not for Button.
el_Salmon
My apologies for not reading your question thoroughly. Is there a reason you don't want to just resize the drawable resources themselves?
QRohlf
Yes, I want to design an application for several size screens, so I expect the Android system resizes the drawable resources according to the display size.
el_Salmon
Then you're looking for this: http://developer.android.com/guide/practices/screens_support.html
QRohlf