NEXTGENINTL
NEXTGENINTL

Reputation: 33

How to size image to its original size

Android's imageView has a serious flaw: it makes my image into a square frame, with the rest as white space. How can I fix this? I have tried scale type, but it didn't work. Thank you. This is the original image

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/header"
        android:scaleType="fitStart"
        android:src="@drawable/img_001" />

</RelativeLayout>

The problem

Upvotes: 0

Views: 292

Answers (1)

jcw
jcw

Reputation: 5162

Without your code I can only guess, but I suggest that you add either the xml attribute android:adjustViewBounds="true" or in your activity, give the imageview that attribute with imageView.setAdjustViewBounds(true)

Upvotes: 1

Related Questions