In the layout below I expect the rows to have exact heights first row 178px and the next two of 71px. Instead I am getting the bottom two with a few extra pixels. What am I doing wrong or is the tablelayout just not as precise as I like?
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="480px"
android:layout_height="320px"
android:background="@drawable/screen"
android:padding="0dp"
android:layout_margin="0dp"
android:stretchColumns="0"
android:weightSum="320" >
<TableRow android:layout_weight="178" android:padding="0dp" android:layout_margin="0dp">
<TextView
android:text=""
android:gravity="center_horizontal"
android:background="#99aa0000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
/>
</TableRow>
<TableRow android:layout_weight="71" android:padding="0dp" android:layout_margin="0dp">
<TextView
android:text=""
android:gravity="center_horizontal"
android:background="#990000aa"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:layout_margin="0dp" />
</TableRow>
<TableRow android:layout_weight="71" android:padding="0dp" android:layout_margin="0dp">
<TextView
android:text=""
android:gravity="center_horizontal"
android:background="#9900aa00"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
android:layout_margin="0dp"
/>
</TableRow>
</TableLayout>
</blink>
The layout_height for the TableRows did not affect it either, it seems in 3.0 the TableLayout works as expected but older versions are weird. A friend suggested I try similar approach with LinearLayout and it actually worked:
As for the exact pixel dimensions, I am fully aware its not recommended, I was just testing how the rows are scaling and using it as an example to display my problem.