0

i am having a image of large height around 2000dp. i wanna display it in ImageView , that can scroll up to its height. i wrote the following xml file , it works fine on devices but not on HTC one X , Samsung galaxy S4 , etc i thing its the issue with large screen mobile devices , can anyone help me out . i will be highly thankful to him/her.

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="2000dp"
    android:layout_below="@+id/total"
    android:scrollbars="vertical" >

    <FrameLayout
        android:id="@+id/relativeLayout"
        android:layout_width="fill_parent"
        android:layout_height="2000dp" >

        <RelativeLayout
            android:id="@+id/upperRelativeLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </RelativeLayout>

        <ImageView
            android:id="@+id/image1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:scaleType="fitXY"
            android:src="@drawable/dayview_bg" />

        <ImageView
            android:id="@+id/image2"
            android:layout_width="fill_parent"
            android:layout_height="2dp"
            android:background="@android:color/white"
            android:scaleType="fitXY" />
    </FrameLayout>
</ScrollView>
Pranav Sharma
  • 692
  • 2
  • 9
  • 22

1 Answers1

-1

You should try to downsize your image to 1) match the device screen size and 2) to avoid memory issues, 2000dp is above the regular dimensions of existing standard devices.

You could follow the documentation to define the different layouts depending on targeted devices :

  • res/layout/my_layout.xml // layout for normal screen size ("default")
  • res/layout-small/my_layout.xml // layout for small screen size
  • res/layout-large/my_layout.xml // layout for large screen size
  • res/layout-xlarge/my_layout.xml // layout for extra large screen size
  • res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

Configuration examples

To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:

  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

If you don't want to downsize the entire image, the BitmapRegionDecoder class could help you (a case of use can be found in this post)

Community
  • 1
  • 1
cdesir
  • 139
  • 5
  • 1
    i have a large image , thats why i used a scrollview to scroll it up and down , why u r telling about supporting multiple screens , thats not what i ask . – Pranav Sharma Oct 01 '13 at 18:28
  • Due to limited memory on most devices, your image cannot stay on memory (out of memory issue); you could try to shrink it, display part of its in your layout, use a webview that has a built-in zoom feature (load image using in an HTML page) – cdesir Oct 01 '13 at 18:36
  • The [BitmapRegionDecoder class](https://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html) could help you (a case of use can be found in [this post](http://stackoverflow.com/a/12161993)) – cdesir Oct 01 '13 at 18:39