解決策を見つけるのにうんざりしている場合。私のように、独自のロジックで KeyboardView の onDraw() をオーバーライドする必要があります。
public class MyKeyboardView extends android.inputmethodservice.KeyboardView {
Context context;
public MyKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
this.context = context ;
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setTextAlign(Paint.Align.CENTER);
paint.setTextSize(25);
paint.setColor(Color.RED);
List<Key> keys = getKeyboard().getKeys();
for(Key key: keys) {
if(key.pressed){
NinePatchDrawable npd = (NinePatchDrawable)context.getResources().getDrawable(R.drawable.glow);
npd.setBounds(key.x,key.y,key.x+key.width,key.y+key.height);
npd.draw(canvas);
if(key.label != null)
canvas.drawText(key.label.toString(), key.x + (key.width/2), key.y + 25, paint);
}else if(key.modifier){ // boolean that defines key is function key
NinePatchDrawable npd = (NinePatchDrawable)context.getResources().getDrawable(R.drawable.btn_keyboard_special);
npd.setBounds(key.x,key.y,key.x+key.width,key.y+key.height);
npd.draw(canvas);
if(key.label != null)
canvas.drawText(key.label.toString(), key.x + (key.width/2), key.y + 25, paint);
}
break;
}
}