【问题标题】:MediaStore Thumbnail images looks blurryMediaStore 缩略图图像看起来模糊
【发布时间】:2016-04-11 11:28:51
【问题描述】:

我正在尝试获取图像并在 Grid 中显示,效果很好,但图像看起来很模糊。

以下是我尝试过的:(按降序排列)

final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
        final String orderBy = MediaStore.Images.Media._ID + " DESC";
        cursor = getActivity().getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
                null, orderBy);
        int image_column_index = cursor.getColumnIndex(MediaStore.Images.Media._ID);
        this.count = cursor.getCount();
        this.arrPath = new String[this.count];
        ids = new int[count];
        for (int i = 0; i < this.count; i++) {
            cursor.moveToPosition(i);
            ids[i] = cursor.getInt(image_column_index);
            int dataColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
            arrPath[i] = cursor.getString(dataColumnIndex);
        }

请帮我更正代码。

【问题讨论】:

  • 你是如何生成位图的?你能更新你的代码吗

标签: android gridview android-image android-gallery


【解决方案1】:

最好的方法是使用recent-images 库。就是这么简单。只需将库依赖项添加到您的项目中,然后将下面的行添加到您的类中。您的适配器已准备就绪,您可以为您的 gridview 设置它。

RecentImages ri = new RecentImages();
ImageAdapter adapter = ri.getAdapter(MainActivity.this);

它有一些选项可以自定义您对图像的查询。

【讨论】:

  • 我在上面的库中发现了一个错误,图像在网格中倾斜,你知道有没有其他类似的库?
  • don't post identical answers to multiple questions。发布一个好的答案,然后投票/标记以关闭其他问题作为重复问题。如果问题不是重复的,调整您对该问题的回答
猜你喜欢
  • 1970-01-01
  • 2016-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-24
  • 2020-10-09
相关资源
最近更新 更多