Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image not stretching inside imageView android

I am having a layout in with root Relative layout and and ImageView inside it when i set it source the Image is not fitting inside into Image view leaving Top and and bottom padding which is in preview but not defined in xml. I want to know how to stretch image to fit completely in ImageView.

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#fff">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/place_demo_2"
        android:id="@+id/back_ground_place"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="400dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Manila Main"
        android:id="@+id/visit_place_title"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="68dp"
        android:textColor="#fff"/>
</RelativeLayout>

Preview

like image 251
Faisal Naseer Avatar asked Dec 07 '25 07:12

Faisal Naseer


1 Answers

Using Code:

YourImageView.SetScaleType(ImageView.ScaleType.FIT_XY);

Using xml:

android:scaleType="fitXY"

See also below snapshots for other alternative options. enter image description here

like image 137
David Avatar answered Dec 09 '25 21:12

David