0

我正在使用 gridview 来显示此处描述的图像http://developer.android.com/guide/topics/ui/layout/gridview.html

我的适配器 getView() 方法是:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        Log.i("count",""+1);
        ImageView imageView;
        ViewHolder holder = null;
        if (convertView == null) {
            imageView = new ImageView(context);
            imageView.setLayoutParams(new GridView.LayoutParams(85, 95));
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            imageView.setPadding(3, 3, 3, 3);


        }
        else{
            imageView = (ImageView) convertView;

        }
        String bookTemp = books.get(position);
       imageView.setImageDrawable(context.getResources().getDrawable(R.drawable.book1));
        //imageView.setImageResource(R.drawable.book2);
        return imageView;
    }

但是我的设备显示的图像是模糊的。我也尝试过改变尺寸,但每次结果都是一样的。我没有明白我在这里做错了什么?我还附上了下面的示例图片,我正在使用它测试。

在此处输入图像描述

4

1 回答 1

0

抱歉,我不得不根据文档回答您的上述问题:
android 将根据图像放置在以下文件夹中的位置来处理图像。

ldpi: Low-density screens; approximately 120dpi.
mdpi: Medium-density (on traditional HVGA) screens; approximately 160dpi.
hdpi: High-density screens; approximately 240dpi.
xhdpi: Extra high-density screens; approximately 320dpi. Added in API Level 8
nodpi: This can be used for bitmap resources that you do not want to be scaled to match the device density.
tvdpi: Screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. This qualifier was introduced with API level 13.

有关这些内容的更多信息,请单击

于 2013-03-28T09:34:54.250 回答