[英]Fill Transparent in Intersection of RectF Android
I have customized button and Im filling Button Color using onDraw and Canvas.. Suppose my Button Parameters(Left,Top,Right,Bottom) are (0,0,200,200) then for the part(20,20,180,180) I want this part transparent and other part with gradient color.. 我已经使用onDraw和Canvas定制了按钮和Im填充按钮颜色。带有渐变颜色的部分。
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
int[] iColor = {
CommonFunctions
.getLightColor(bAppointments.getSrtStatus(), 255),
CommonFunctions.getColor(bAppointments.getSrtStatus(), 255) };
int[] gapColor = { Color.argb(255, 255, 255, 255),
Color.argb(255, 255, 255, 255) };
float[] iPos = {
0,
(canvas.getClipBounds().bottom - canvas.getClipBounds().top) / 2 };
LinearGradient lGradient = new LinearGradient(
canvas.getClipBounds().right - canvas.getClipBounds().left,
canvas.getClipBounds().top, canvas.getClipBounds().right
- canvas.getClipBounds().left,
canvas.getClipBounds().bottom, iColor, iPos,
Shader.TileMode.CLAMP);
mPaint.setAlpha(0xBB);
mPaint.setShader(lGradient);
mPaint.setStyle(Style.FILL);
mRectF.set(canvas.getClipBounds().left + 2,
canvas.getClipBounds().top + 2,
canvas.getClipBounds().right - 2,
canvas.getClipBounds().bottom - 6);
canvas.drawRoundRect(mRectF, rectCurve, rectCurve, mPaint);
}
Currently my Layout Look Like 目前我的布局看起来像
for now..I have done it using temporary solution.. I filled transparent to the button first.. then I divided the Button Canvas into 5 part.. 目前,..我已经使用临时解决方案完成了..我先对按钮填充透明..然后将“按钮画布”分为5部分。
Top Part, Left Part, Gap Part, Right Part and Bottom Part.. n I filled that part using the same Paint object.. 顶部,左侧部分,间隙部分,右侧部分和底部部分。n我使用相同的Paint对象填充了该部分。
Still waiting for the good solution.. 仍在等待好的解决方案。
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.