Kenny
Kenny

Reputation: 489

ScrollView does not stretch ImageView to fit screen?

I am using a ScrollView to hold and display a static map image, which is 480 px x 904 px in size, and is implemented so that I can scroll up and down to view the map. I have implemented so that the ScrollView should fit and fill the screen. However, it does not appear to be able to stretch the map image to fit screen and I am not sure what I did wrong. The map image is a 9-patch image where only the right edge is allowed to stretch.

Here is the XML code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rlayoutResultMap"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="0dp" >

    <ScrollView
        android:id="@+id/scrollResultMap"
        android:fillViewport="true" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:scrollbars="none" >

        <RelativeLayout
            android:id="@+id/rlayoutScrollMap"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <ImageView
                android:id="@+id/imgResultMap"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_alignParentTop="true"
                android:src="@drawable/map_base"/>

        </RelativeLayout>
    </ScrollView>

    <ImageButton
        android:id="@+id/btnBack"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:background="@android:color/transparent"
        android:contentDescription="@string/btnBack_desc"
        android:scaleType="centerInside"
        android:src="@drawable/back_button" />

    <TextView
        android:id="@+id/tickerWeather"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="#80000000"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="@string/weather_feed_init_text"
        android:textColor="#ffffffff" />

    <ImageView
        android:id="@+id/imgMapZoom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/tickerWeather"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="5dp"
        android:layout_marginRight="10dp"
        android:src="@drawable/map_zoom_icon" />

</RelativeLayout>

Thanks in advance.

Upvotes: 0

Views: 2145

Answers (1)

ChristopheCVB
ChristopheCVB

Reputation: 7315

Try using scaleType attribute on your ImageView, here is the documentation.

Upvotes: 2

Related Questions