0
我正在處理一個Android鍵盤項目。我想在Android自定義鍵盤中更改KeyLabel
的字體大小。更改KeyLabel字體大小在<key>標記爲特定鍵
我正在處理一個Android鍵盤項目。我想在Android自定義鍵盤中更改KeyLabel
的字體大小。更改KeyLabel字體大小在<key>標記爲特定鍵
幾天以後,我找到了辦法!我在我的CustomKeyboardView
課中使用了canvas
,所以我只是用一個條件來繪製它:\
public class CustomKeyboardView extends KeyboardView {
public CustomKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
canvas.drawPaint(paint);
paint.setColor(Color.WHITE);
paint.setTextSize(16);
boolean abc = false ;
List<Keyboard.Key> keys = getKeyboard().getKeys();
for (Keyboard.Key key : keys) {
if (key.codes[0] == -2)
{
canvas.drawText("My Text", key.x, key.y, paint);
}
}
}
}