Fix missing background where multiple KeyButtonViews are rendered in the

same window

getLeft(), getRight(), getTop(), getBottom() return coords in the entire
window, while drawOval asks for coords in the current view. This is not
an issue where only one KeyButtonView is in the layout, but it is when
there are more than one.

Fixes: 177153730
Test: Manual test with ag/q/topic:"game-dashboard-entry-point"

Change-Id: If781eb3cb98a3dfb6e51c431fec7f6ae909ef3a3
This commit is contained in:
Tracy Zhou
2021-01-09 23:47:19 -08:00
parent 8337a179d4
commit 74cad9cfb4

View File

@@ -461,14 +461,8 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
@Override
public void draw(Canvas canvas) {
if (mHasOvalBg) {
canvas.save();
int cx = (getLeft() + getRight()) / 2;
int cy = (getTop() + getBottom()) / 2;
canvas.translate(cx, cy);
int d = Math.min(getWidth(), getHeight());
int r = d / 2;
canvas.drawOval(-r, -r, r, r, mOvalBgPaint);
canvas.restore();
canvas.drawOval(0, 0, d, d, mOvalBgPaint);
}
super.draw(canvas);
}