Search code examples
androidandroid-relativelayoutalignment

Android RelativeLayout alignParentRight does not properly align Imageview


I am trying to place my ImageView in the bottom right corner of my display. I would like for the image to expand dynamically for different size displays.

The image aligns properly when it is smaller and not set to expand, but when set it to fill_parent the image is moved to the left and no longer lines up flush with the right side of the display.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <SurfaceView 
        android:id="@+id/surface1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        ></SurfaceView>
    <ImageView 
        android:src="@+drawable/image_1_patched" 
        android:layout_height="fill_parent" 
        android:id="@+id/imageView1" 
        android:layout_width="fill_parent"
        android:layout_alignParentRight="true"
        ></ImageView>
</RelativeLayout>

How can I make the image take up as much room as possible and remain flush to the right side of the display?


Solution

  • Set the scaletype of your imageview to FIT_XY.