在android

时间:2017-12-19 03:59:25

标签: android android-recyclerview android-camera scrollview

嗨我在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:

<?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>

1 个答案:

答案 0 :(得分:1)

始终对工作线程执行复杂操作或使用{/ 1}},如

AsyncTask添加以下课程

Adapter

在Bind Holder方法

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);
    }
 ..
}