public class GrayscaleImageView extends ImageView { public GrayscaleImageView(Context context) { super(context); } public GrayscaleImageView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onDraw(Canvas canvas) { ColorMatrix cm = new ColorMatrix(); cm.setSaturation(0); Paint paint = new Paint(); paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(((BitmapDrawable) getDrawable()).getBitmap(), 0, 0, paint); } }This example creates a new `ImageView` called `GrayscaleImageView`, which extends the `ImageView` class. In the `onDraw()` method, a `ColorMatrix` object is used to set the saturation of the image to 0, effectively removing all colors. A `Paint` object is created with a `ColorMatrixColorFilter` that will apply the `ColorMatrix` to the bitmap. Finally, the modified bitmap is drawn on the canvas. The package library for `android.widget.ImageView` is `android.widget`.