setImageDrawable图像模糊不清

时间:2013-03-28 09:07:40

标签: android imageview android-gridview

我正在使用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;
    }

但是我的设备显示的图像很模糊。我也试过改变尺寸,但每次结果都是一样的。我不知道我在这里做错了什么?我还附上了下面的示例图片我也是我正在用于测试。

enter image description here

1 个答案:

答案 0 :(得分: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.

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