Search code examples
androidlayouttablelayoutdpi

How to remove TableLayout padding in ldpi layout


I am putting two images in a row, its goes well on hdpi and mdpi, but I try to open it in ldpi , the layout just get disturbed by unknown padding (dont know what it is)

Correct image in hdpi and mdpi (how it should be displayed)

https://i.sstatic.net/OXw9G.png

Wrong image in ldpi

https://i.sstatic.net/wR3kw.png

code is the same, but dont know what happening in ldpi mode.

<TableLayout  
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*"
        android:background="@color/Grey">

        <TableRow>
            <FrameLayout 
                android:id="@+id/inboxLargeButton"
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                android:layout_weight="1">

                <ImageView android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" 
                    android:src="@drawable/inbox_normal" 
                    android:id="@+id/buttonWeddingDayCheatSheet"
                    android:layout_gravity="center_horizontal">
                </ImageView>
                <TextView  
                    android:layout_width="fill_parent"  
                    android:layout_height="wrap_content"  
                    android:text="2631"  
                    android:layout_gravity="bottom"  
                    android:gravity="center"  
                    android:textColor="#fff"  
                    android:textSize="50dp" />
            </FrameLayout>

            <FrameLayout 
                android:id="@+id/outboxLargeButton"
                android:layout_height="wrap_content"
                android:layout_width="0dp"
                android:layout_weight="1">
                <ImageView android:layout_width="wrap_content" 
                    android:layout_height="wrap_content" 
                    android:src="@drawable/ourbox_normal" 
                    android:id="@+id/buttonShareFavoriteRecipe"
                    android:layout_gravity="center_horizontal">
                </ImageView>
                <TextView  
                    android:layout_width="fill_parent"  
                    android:layout_height="wrap_content"  
                    android:text="0296"  
                    android:layout_gravity="bottom"  
                    android:gravity="center"  
                    android:textColor="#fff"  
                    android:textSize="50dp" />
                </FrameLayout>
        </TableRow>
</TableLayout>

In ldpi, its also showing extra padding between rows in subsecuent rows of images.

Any help?


Solution

  • As per earlier comment:

    It's not unlikely the images are larger than visually required on ldpi, resulting in a scale down. By default, the bounds of the view do not change when downscaling. Try setting android:adjustViewBounds="true" to the ImageViews.