CircleFramedDrawable incorrectly has implicit dependency on the hosting view size.
CircleFramedDrawable was trying to draw itself as big as the hosting view by looking at the canvas size. However, due to inconsistent API behavior for the cases with and without hardware acceleration the canvas size returns the size of clipped canvas or the size of the entire canvas, respectively. While we should fix the inconsistent API behavior, it is not correct for a lower level component to know about the higher level one, i.e. a drawable trying to infer the size of the hosting view. The hosting view should set the size of the drawable. This change removes the dependency on the host view size and if one wants to enlarge the drawable, he/she should just set the scale. bug:8671059 Change-Id: Idc572da7dff60fd10cb37d3c3eca27aac2c0a21f
This commit is contained in:
@@ -123,12 +123,10 @@ class CircleFramedDrawable extends Drawable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
// clear background
|
final float inside = mScale * mSize;
|
||||||
final float outside = Math.min(canvas.getWidth(), canvas.getHeight());
|
final float pad = (mSize - inside) / 2f;
|
||||||
final float inside = mScale * outside;
|
|
||||||
final float pad = (outside - inside) / 2f;
|
|
||||||
|
|
||||||
mDstRect.set(pad, pad, outside - pad, outside - pad);
|
mDstRect.set(pad, pad, mSize - pad, mSize - pad);
|
||||||
canvas.drawBitmap(mBitmap, mSrcRect, mDstRect, null);
|
canvas.drawBitmap(mBitmap, mSrcRect, mDstRect, null);
|
||||||
|
|
||||||
mFrameRect.set(mDstRect);
|
mFrameRect.set(mDstRect);
|
||||||
|
Reference in New Issue
Block a user