Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying an image larger than the device's screen

I'd like to display an image larger, in size, than a device's screen without resizing the image. It has to be centered on the screen. How can I do this?

like image 935
eyal Avatar asked Jun 23 '11 07:06

eyal


2 Answers

use scrollview with image view and set height of that scroll view

Example

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <ImageView
        android:id="@+id/accountIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</ScrollView>
like image 158
Sunil Kumar Sahoo Avatar answered Sep 20 '22 01:09

Sunil Kumar Sahoo


I noticed that I need to use normal (vertical) and horizontal ScrollView in order to scroll both directions. Let me know please if there is another way.

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollView" >
    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/horizontalScrollView">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView3"
            android:src="@drawable/big_map"/>
        </HorizontalScrollView>
</ScrollView>

It started display form left upper corner of the image. If I tried to use android:layout_gravity="center" then I got white part on right or bottom. So centering is not working for me.

Option 2: use WebView control, and load it with image onCreate.

like image 27
Deleted because of negativity Avatar answered Sep 18 '22 01:09

Deleted because of negativity