嗨我已经在scroll-View里面插入了Recycler-View,当我在Recycler-View里面添加了多个图像,然后滚动视图没有正确滚动,一段时间后它会自动崩溃,我觉得它的图像高分辨率问题可以帮助我一些人
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "New Picture");
values.put(MediaStore.Images.Media.DESCRIPTION, "From your Camera");
imageUri = getActivity().getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, Constants.CAMERA_REQUEST_CODE);
thumbnail = Bitmap.createScaledBitmap(BitmapFactory.decodeFile("" + shopImageFile),
100, 100, true);
shop_image.setImageBitmap(thumbnail);
Utilities.setEmptyError(business_name_layout);
setImageMargins(shop_image);
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:fillViewport="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:layout_marginLeft="16dp"
android:layout_marginTop="3dp" />
</Scrollview>
始终在工作线程上执行复杂操作或使用AsyncTask
,如
在你的Adapter
添加以下课程
static class ImageLoader extends AsyncTask<>{
private ImageView shop_image;
ImageLoader(ImageView shop_image){
this.shop_image = shop_image;
}
..
public Bitmap doInBackground(){
return Bitmap.createScaledBitmap(BitmapFactory.decodeFile("" + shopImageFile),
100, 100, true);
}
public void onPostExecute(Bitmap thumbnail){
shop_image.setImageBitmap(thumbnail);
Utilities.setEmptyError(business_name_layout);
setImageMargins(shop_image);
}
..
}
在Bind Holder方法中
new ImageLoader().execute();