Crazzi_Boii
Crazzi_Boii

Reputation: 644

RelativeLayout Imageview android:layout_height="wrap_content" not woking

enter image description here

Here the i get stuck as the picture i gave is not aligned to top there is a space in between the top bar n the picture. Even i did not gave any margin or any padding values.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/udacity"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
    />
</RelativeLayout>

Upvotes: 0

Views: 55

Answers (3)

Crazzi_Boii
Crazzi_Boii

Reputation: 644

i finally use android:scaleType="fitXY" n got the correct output . . Shareing the code . .

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <ImageView
        android:id="@+id/udacityImg1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/udacity"
        android:scaleType="fitXY"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
    />
</RelativeLayout>

Upvotes: 0

Suhanshu Patel
Suhanshu Patel

Reputation: 45

Your ImageView is aligned correctly but the space which is seen, caused by the image inside imageview itself . So use "scaleType" attribute.

Upvotes: 0

Sergio Rodriguez
Sergio Rodriguez

Reputation: 83

Have you tried scaling the image? try adding this to the imageView android:scaleType="fitXY"

Upvotes: 1

Related Questions