【问题标题】:How to remove TableLayout padding in ldpi layout如何在 ldpi 布局中删除 TableLayout 填充
【发布时间】:2013-07-20 05:14:40
【问题描述】:

我连续放两张图片,它在 hdpi 和 mdpi 上运行良好,但我尝试在 ldpi 中打开它,布局只是被未知填充干扰(不知道它是什么)

hdpi 和 mdpi 中的正确图像(应该如何显示)

http://i.stack.imgur.com/OXw9G.png

ldpi 中的图像错误

http://i.stack.imgur.com/wR3kw.png

代码是一样的,但不知道在ldpi模式下发生了什么。

<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>

在 ldpi 中,它还会在图像的后续行之间显示额外的填充。

有什么帮助吗?

【问题讨论】:

  • 图片在ldpi 上大于视觉要求的可能性不大,导致缩小。默认情况下,视图的边界在缩小时不会改变。尝试将android:adjustViewBounds="true" 设置为ImageViews。
  • 有效!! :) 你拯救了我的一天@MH。
  • 很高兴听到!我应该将评论移至您接受的答案吗?

标签: android layout tablelayout dpi


【解决方案1】:

根据之前的评论:

ldpi 上,图像大于视觉要求的可能性不大,从而导致缩小。默认情况下,视图的边界在缩小时不会改变。尝试将android:adjustViewBounds="true" 设置为ImageViews。

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 2021-09-15
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多