jjNford
jjNford

Reputation: 5270

ImageView layout

Essentially I'm looking for something like scaleType="centerCrop" without the center.

I am having trouble making an ImageView display correctly when it's larger than the screen dimensions. I'm trying to display an ImageView that starts top=0, left=0 and is not scaled. It's okay that the image does not fit on the screen. Right now I have it in a relative layout:

<?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:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/postagram_blank_large"/>
</RelativeLayout>

I've tried using a wrap_content on the RelativeLayout height and width. I've also played with scaleType as well as using a Scrollview. The problem with the ScrollView is that the image is both taller and wider than the display port (again this is meant to happen).

How can I make this work?

Upvotes: 0

Views: 959

Answers (2)

Naveen
Naveen

Reputation: 1703

Try this:

<ImageView
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:src="@drawable/postagram_blank_large"
    android:scaleType="matrix"
    />

wrap_content instead of fill_parent also works, use whatever you want

Upvotes: 0

SimonSays
SimonSays

Reputation: 10977

could it be that android:background scales the image to the screensize? try to use android:src instead.

Upvotes: 1

Related Questions