summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
index a00fab3..bb0ce16 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
@@ -52,6 +52,7 @@ public class KeyButtonView extends ImageView {
int mCode;
int mTouchSlop;
Drawable mGlowBG;
+ int mGlowWidth, mGlowHeight;
float mGlowAlpha = 0f, mGlowScale = 1f, mDrawingAlpha = 1f;
boolean mSupportsLongpress = true;
RectF mRect = new RectF(0f,0f,0f,0f);
@@ -89,6 +90,8 @@ public class KeyButtonView extends ImageView {
mGlowBG = a.getDrawable(R.styleable.KeyButtonView_glowBackground);
if (mGlowBG != null) {
setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
+ mGlowWidth = mGlowBG.getIntrinsicWidth();
+ mGlowHeight = mGlowBG.getIntrinsicHeight();
}
a.recycle();
@@ -103,8 +106,12 @@ public class KeyButtonView extends ImageView {
canvas.save();
final int w = getWidth();
final int h = getHeight();
+ final float aspect = (float)mGlowWidth / mGlowHeight;
+ final int drawW = (int)(h*aspect);
+ final int drawH = h;
+ final int margin = (drawW-w)/2;
canvas.scale(mGlowScale, mGlowScale, w*0.5f, h*0.5f);
- mGlowBG.setBounds(0, 0, w, h);
+ mGlowBG.setBounds(-margin, 0, drawW-margin, drawH);
mGlowBG.setAlpha((int)(mDrawingAlpha * mGlowAlpha * 255));
mGlowBG.draw(canvas);
canvas.restore();