Android 编程绘制的图标在某些设备上是像素化的

Android 编程绘制的图标在某些设备上是像素化的,android,bitmap,imageview,icons,android-canvas,Android,Bitmap,Imageview,Icons,Android Canvas,我在代码中创建了一个图标,它在大多数设备上都显示得很好,但在一些设备上,它显示的都是像素化的。我已经尝试过创建不同密度的图标,并查看是否将其文件手动存储在res文件夹中,以获得不同的密度,但事实并非如此 // ------------------------------------------------------------------------- // draw bitmap icon image using Canvas and store in database as BLOB //

我在代码中创建了一个图标,它在大多数设备上都显示得很好,但在一些设备上,它显示的都是像素化的。我已经尝试过创建不同密度的图标,并查看是否将其文件手动存储在res文件夹中,以获得不同的密度,但事实并非如此

// -------------------------------------------------------------------------
// draw bitmap icon image using Canvas and store in database as BLOB
// -------------------------------------------------------------------------
Bitmap bmpBase = Bitmap.createBitmap( 120, 120, Bitmap.Config.ARGB_8888 );
...
Canvas canvas = new Canvas( bmpBase );
...
canvas.drawCircle( x, y, radius, paint );

// convert icon bitmap to PNG and extract as BLOB to store in database
ByteArrayOutputStream baos = new ByteArrayOutputStream();  
bmpBase.compress( Bitmap.CompressFormat.PNG, 100, baos );   
buffer = baos.toByteArray();


// ------------------------------------------------------------
// get icon BLOB from database as Bitmap and set in ImageView
// ------------------------------------------------------------
...
ByteArrayInputStream imageStream = new ByteArrayInputStream(iconBlob);
Bitmap iconBitmap = BitmapFactory.decodeStream(imageStream);

// Set ImageView to our icon bitmap
ImageView imageView = (ImageView) view.findViewById(R.id.row_icon);
imageView.setImageBitmap(iconBitmap);
ImageView的布局

<RelativeLayout
    android:id="@+id/row_icon_first"
    android:layout_width="20dp"
    android:layout_height="20dp"  >

    <ImageView
        android:id="@+id/row_icon"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"/>
</RelativeLayout>

试着放 android:adjustViewBounds=“true”