0

good morning i would like to scroll a large image in my Android app the size of my image is 800 * 3782 px every time i get error of memory the size of the image is 1.7Mb with 72 dpi resolution. this is the xml :

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"

     >
<HorizontalScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ScrollView
                android:id="@+id/scrollView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"/>
            </ScrollView>
  </HorizontalScrollView> 
</LinearLayout>

this the java class:

public class About extends Activity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.about);
        ImageView iv = (ImageView) findViewById(R.id.imageView1);


        Resources res = getResources();
        BitmapDrawable bitmap = (BitmapDrawable) res.
             getDrawable(R.drawable.aboutscroll);
        int imgW = bitmap.getIntrinsicWidth();
        int imgH = bitmap.getIntrinsicHeight();

        iv.setImageDrawable(bitmap);

        ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) iv.getLayoutParams();
        params.width = imgW;
        params.height = imgH;
    }


}

i got this trace of error :

08-27 09:51:10.175: E/AndroidRuntime(1578): FATAL EXCEPTION: main
08-27 09:51:10.175: E/AndroidRuntime(1578): java.lang.OutOfMemoryError
08-27 09:51:10.175: E/AndroidRuntime(1578):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-27 09:51:10.175: E/AndroidRuntime(1578):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)

if someone can help me please.

Walid Sassi
  • 75
  • 1
  • 2
  • 11
  • i used this question but no result usually memory pb http://stackoverflow.com/questions/3058164/android-scrolling-an-imageview – Walid Sassi Aug 27 '14 at 17:18

1 Answers1

0

"Out of memory error" means image file is too big.. if you reduce, then no more error. :)