0
我有LinearLayout包含一些意见。是否可以这样做,以使LinearLayout内的所有内容都以灰度色彩模式绘制?如何在android上查看desaturate?
我有LinearLayout包含一些意见。是否可以这样做,以使LinearLayout内的所有内容都以灰度色彩模式绘制?如何在android上查看desaturate?
您需要扩展LinearLayout并重写dispatchDraw方法。
然后创建一个大小为LinearLayout和画布的位图。并用新的画布作为参数调用super.dispatchDraw。之后,您可以使用设置ColorFilter的颜料在原始Canvas上绘制位图。
这里的例子:
private Bitmap mBitmap;
private Canvas mCanvas;
private Paint mPaint;
public {Constructor}{
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
mPaint.setColorFilter(colorFilter);
}
@Override
public void onSizeChanged(int w, int h, in oldw, int oldh){
mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
mCanvas = new Camvas(mBitmap);
}
@Override
public void dispatchDraw(Canvas canvas){
super.dispatchDraw(mCanvas);
canvas.drawBitmap(mBitmap, 0, 0, mPaint);
}
设置布局为禁用? – 2016-05-16 13:40:37
你的意思是这样的:http://stackoverflow.com/questions/7068873/how-can-i-disable-all-views-inside-the-layout? – AsfK