Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ImageView to make a 2D Map of Icons
    primarykey
    data
    text
    <p>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):</p> <p> </p> <pre><code>&lt;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" &gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="0px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="48px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="96px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="144px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="192px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="240px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="288px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="336px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="384px" android:layout_y="0px" /&gt; &lt;ImageView android:background="@drawable/water2" android:layout_width="48px" android:layout_height="48px" android:layout_x="0px" android:layout_y="48px" /&gt; &lt;/AbsoluteLayout&gt; </code></pre> <p></p> <p>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.</p> <p>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.</p> <p>Thanks.</p> <p>So I changed the XML file to try and use the TableLayout as follows:</p> <p> </p> <pre><code>&lt;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" &gt; &lt;TableRow&gt; &lt;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"&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;ImageView android:src="@drawable/water2" android:scaleType="fitXY" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p></p> <p>Even if I specified the exact dimensions of the ImageViews, they still got stretched such that only about 5 or so icons were displayed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload