Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align unknown height image along bottom of RelativeLayout

I need to have a screen with an image laid out along the bottom of the screen. The image itself is fixed (from resources). It's quite large and is scaled down to the width of each device. I tried to use simple layout_alignParentBottom, like so:

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

Yes, this didn't work. Unless I specify exact height of the image (in place of wrap_content), the ImageView is not aligned at the bottom. Most likely this is due to the fact that the actual image is higher than the screen size and becomes "shorter" only after scaled down to the width of the screen.

So, the question is how do I get the ImageView to stay at the bottom of the screen regardless of the size of the device?

like image 538
Aleks G Avatar asked Nov 24 '25 12:11

Aleks G


1 Answers

add to your imageview in xml android:adjustViewBounds="true"

like image 200
Mohammad Ersan Avatar answered Nov 27 '25 02:11

Mohammad Ersan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!