【问题标题】:Align unknown height image along bottom of RelativeLayout沿RelativeLayout底部对齐未知高度图像
【发布时间】:2012-12-13 04:47:24
【问题描述】:

我需要在屏幕底部放置一个带有图像的屏幕。图像本身是固定的(来自资源)。它非常大,并且按比例缩小到每个设备的宽度。我尝试使用简单的layout_alignParentBottom,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LayoutLoading"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/startup" >

    <ImageView
        android:id="@+id/ImageView01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:scaleType="fitCenter"
        android:src="@drawable/loading" />

</RelativeLayout>

是的,这不起作用。除非我指定图像的确切高度(代替wrap_content),否则ImageView 不会在底部对齐。这很可能是由于实际图像高于屏幕尺寸,并且只有在缩小到屏幕宽度后才会“变短”。

那么,问题是如何让ImageView 保持在屏幕底部而不管设备的大小?

【问题讨论】:

  • 旁注:您可以删除android:orientation="vertical",因为它似乎是LinearLayout 方法的剩余部分。 :)
  • @ninetwozero 是的,你是对的,谢谢。

标签: android image layout


【解决方案1】:

在 xml 中添加到您的 imageview android:adjustViewBounds="true"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-09
    • 1970-01-01
    • 2012-11-04
    相关资源
    最近更新 更多