Android program dynamic setting of ImageView brightness
- 2021-01-03 21:02:41
- OfStack
Without further ado, I will post the code directly to you.
// Method of changing the brightness of the picture 0-- The same >0--- The bright <0--- dim
private void changeLight(ImageView imageView, int brightness) {
ColorMatrix cMatrix = new ColorMatrix();
cMatrix.set(new float[] { 1, 0, 0, 0, brightness, 0, 1, 0, 0,
brightness,// Change the brightness
0, 0, 1, 0, brightness, 0, 0, 0, 1, 0 });
imageView.setColorFilter(new ColorMatrixColorFilter(cMatrix));
}
Well, the code is relatively simple, I hope to help you.