簡體   English   中英

沿RelativeLayout底部對齊未知高度圖像

[英]Align unknown height image along bottom of RelativeLayout

我需要一個屏幕,屏幕底部放置一個圖像。 圖像本身是固定的(來自資源)。 它非常大,縮小到每個設備的寬度。 我嘗試使用簡單的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保持在屏幕的底部而不管設備的大小?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM