3

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"?

Community
  • 1
  • 1
Jaime M.
  • 3,613
  • 5
  • 32
  • 35

1 Answers1

6

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
  • 2,795
  • 3
  • 24
  • 27
  • 3
    Sorry but scaleType attibute applies for ImageButton, not for Button. – Jaime M. Jul 28 '10 at 13:13
  • My apologies for not reading your question thoroughly. Is there a reason you don't want to just resize the drawable resources themselves? – QRohlf Jul 28 '10 at 16:27
  • 1
    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. – Jaime M. Jul 29 '10 at 08:13
  • Then you're looking for this: http://developer.android.com/guide/practices/screens_support.html – QRohlf Jul 29 '10 at 16:23