Andak
Andak

Reputation: 371

Android ImageView in HorizontalScrollView get's twice the width of screen

I'm trying to make a ImageView inside a HorizontalScrollView, but the imageView gets twice the width of the screen and end halfway out of bounds.

My XML:

<?xml version="1.0" encoding="utf-8"?>

<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:baselineAligned="true"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/penguins" />
</LinearLayout>

</HorizontalScrollView>

And a image of what I get (click me!)

Does anyone know a solution to this problem?

Greetings

Upvotes: 1

Views: 880

Answers (1)

Shirane85
Shirane85

Reputation: 2295

I copied your xml and using my resource it looks perfect, i believe your resource is bigger than you think it is, you probably should use layout_width and layout_height as fix size and also set scaleType to centerInside.

Upvotes: 5

Related Questions