0
早安我想滾動我的Android應用程序中的大圖像我的圖像的大小是800 * 3782 px 每當我收到內存錯誤圖像的大小是1.7Mb與72 dpi解析度。 這是XML:滾動大圖android
<?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>
這個Java類:
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;
}
}
我得到這個錯誤跟蹤:
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)
,如果有人可以幫我請。
任何想法,請 – 2014-08-27 11:06:08
我用這個問題,但沒有結果通常是內存PB http://stackoverflow.com/questions/3058164/android-scrolling-an-imageview – 2014-08-27 17:18:23