问题描述
- 关于BitmapShader创建特殊形状的ImageView的问题
-
安卓的ImageView,如何使用关于BitmapShader创建特殊形状,scale的计算是根据裁剪前的么?
解决方案
http://blog.csdn.net/lmj623565791/article/details/41967509
重点
@Override
protected void onDraw(Canvas canvas)
{
if (getDrawable() == null)
{
return;
}
setUpShader();
if (type == TYPE_ROUND)
{
canvas.drawRoundRect(mRoundRect, mBorderRadius, mBorderRadius,
mBitmapPaint);
} else
{
canvas.drawCircle(mRadius, mRadius, mRadius, mBitmapPaint);
// drawSomeThing(canvas);
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(w, h, oldw, oldh);
// 圆角图片的范围
if (type == TYPE_ROUND)
mRoundRect = new RectF(0, 0, getWidth(), getHeight());
}
时间: 2024-10-29 03:22:17