I have made the same image button in 36x36,48x48,72x72 and 96x96 and put them in the drawable-ldpi,drawable-mdpi,drawable-hdpi directories.
I then created a layout and plonked my image button there.
(I am using Eclipse)
in the top left of the screen you can pick the screen size, so I picked 2.7 inches and then cycled right up till 10.1 inches...and every time my image button size changed.
So my question is, do I need to have a different xml layout file for each screen size?
Thanks!
EDIT XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/background_ass">
<TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="fill_parent">
<TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageButton android:src="@drawable/level1"
android:id="@+id/imageButton1"
android:onClick="button_clicked1"
android:background="#00000000" android:layout_width="48dip" android:layout_height="48dip">
</ImageButton>
</TableRow>
<TableRow android:id="@+id/tableRo开发者_Go百科w2" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</TableRow>
<TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content">
</TableRow>
<TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TableRow>
</TableLayout>
</LinearLayout>
No the point of those separate folders is that, if you provide the same name for that file, the correct resolution file will be chosen based on the screen size. But make sure that you provide the same name for the image. If you see the button resizing accordingly, then you have done this correctly.
精彩评论