自定义&LT的外观;按键&GT; [英] Customize the appearance of a <Key>
问题描述
一些第三方键盘有多个字符的每一个关键,例如更好的键盘8具有数字和标点符号以上各按键上的字母:
Some 3rd party keyboards have more than one character on each key, for example Better Keyboard 8 has numbers and punctuation above the letters on each key:
可以这样用&LT做了什么?如果是的话,我可以不知道怎样。我想AP preciate如果有人知道如何。
Can this be done with the <Key>
tag? If so I cannot figure out how. I would appreciate if anybody knows how.
在此先感谢, 巴里
推荐答案
我想它了,所以我回答我的问题。
I figured it out so I am answering my own question.
有不能在XML中进行,但可以在Java通过重写KeyboardView的的OnDraw()方法来进行。这毫无意义的示例绘制每个按键顶部的小字母后的密钥由父类得出:
It cannot be done in XML, but it can be done in Java by overriding the onDraw() method of KeyboardView. This pointless example draws a small letter at the top of each key after the keys are drawn by the parent class:
public class MyKeyboardView extends KeyboardView {
@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.label != null)
canvas.drawText(key.label.toString(), key.x + (key.width/2), key.y + 25, paint);
}
}
}
这篇关于自定义&LT的外观;按键&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!