So I'm struggling a bit here trying to create a 2D map of icons, where each icon is 48x48 pixels and the map is a 9x9 grid (thus, 432x432 pixels in size). I tried, unsuccessfully, starting with a GridView and have since decided to try using an AbsoluteView inside of a LinearView. Here's the beginning of the XML file (I've not added all 81 icons for now just to keep it somewhat brief for this question):
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="442px"
android:layout_height="442px"
android:padding="5px"
android:layout_gravity="center_horizontal"
android:background="#008000"
>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="0px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="48px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="96px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="144px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="192px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="240px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="288px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="336px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="384px"
android:layout_y="0px"
/>
<ImageView
android:background="@drawable/water2"
android:layout_width="48px"
android:layout_height="48px"
android:layout_x="0px"
android:layout_y="48px"
/>
</AbsoluteLayout>
When I try this in Eclipse, it looks utterly perfect. When I load this onto my Samsung Captivate, it is just wrong. Its as if the icons are being stretched even though I've specified exact dimensions in pixels.
I'm sure I'm probably making some noob mistake, but no matter what I try, I cannot seem to make the icons/drawables display at their exact dimensions. If someone can point out what I'm doing wrong, I would greatly appreciate it.
Thanks.
So I changed the XML file to try and use the TableLayout as follows:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
<TableRow>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="0px">
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:src="@drawable/water2"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</TableRow>
</TableLayout>
Even if I specified the exact dimensions of the ImageViews, they still got stretched such that only about 5 or so icons were displayed.