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.