@@ -52,6 +52,7 @@ public class KeyButtonView extends ImageView {
5252 int mCode ;
5353 int mTouchSlop ;
5454 Drawable mGlowBG ;
55+ int mGlowWidth , mGlowHeight ;
5556 float mGlowAlpha = 0f , mGlowScale = 1f , mDrawingAlpha = 1f ;
5657 boolean mSupportsLongpress = true ;
5758 RectF mRect = new RectF (0f ,0f ,0f ,0f );
@@ -89,6 +90,8 @@ public KeyButtonView(Context context, AttributeSet attrs, int defStyle) {
8990 mGlowBG = a .getDrawable (R .styleable .KeyButtonView_glowBackground );
9091 if (mGlowBG != null ) {
9192 setDrawingAlpha (BUTTON_QUIESCENT_ALPHA );
93+ mGlowWidth = mGlowBG .getIntrinsicWidth ();
94+ mGlowHeight = mGlowBG .getIntrinsicHeight ();
9295 }
9396
9497 a .recycle ();
@@ -103,8 +106,12 @@ protected void onDraw(Canvas canvas) {
103106 canvas .save ();
104107 final int w = getWidth ();
105108 final int h = getHeight ();
109+ final float aspect = (float )mGlowWidth / mGlowHeight ;
110+ final int drawW = (int )(h *aspect );
111+ final int drawH = h ;
112+ final int margin = (drawW -w )/2 ;
106113 canvas .scale (mGlowScale , mGlowScale , w *0.5f , h *0.5f );
107- mGlowBG .setBounds (0 , 0 , w , h );
114+ mGlowBG .setBounds (- margin , 0 , drawW - margin , drawH );
108115 mGlowBG .setAlpha ((int )(mDrawingAlpha * mGlowAlpha * 255 ));
109116 mGlowBG .draw (canvas );
110117 canvas .restore ();
0 commit comments