它在一个视图中,所以setBackground方法应该没问题,我传递Color.BLUE,这绝对是一个合适的int。
public void changeRandomPixel(int color)
{
Bitmap resizedBitmap = Bitmap.createScaledBitmap(intialBitmap, 10, 10, true);
int[] pixels = new int[resizedBitmap.getHeight()* resizedBitmap.getWidth()];
resizedBitmap.getPixels(pixels, 0, resizedBitmap.getWidth(), 0, 0, resizedBitmap.getWidth(), resizedBitmap.getHeight());
Random rand = new Random();
pixels[rand.nextInt(100)] = color;
resizedBitmap.setPixels(pixels, 0, resizedBitmap.getWidth(), 0, 0, resizedBitmap.getWidth(), resizedBitmap.getHeight());
Drawable background = new BitmapDrawable(getResources(), resizedBitmap);
setBackground(background);
}