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