【发布时间】: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