canvas贴文字、斜体
public static void drawGameState(final Canvas canvas, int level, int gold, int score, int time) { Paint paint = new Paint(); String str = "关卡:" + level + " 现金:" + gold + " 得分:" + score + " 时间:" + time; float fontSize = 16; if (mWidth > 480) { fontSize = 26; } paint.setTextSize(fontSize); paint.setColor(Color.argb(128, 0, 0, 2)); paint.setStyle(Paint.Style.FILL); canvas.drawRect(0, 0, mWidth, fontSize + 10, paint); paint.setColor(Color.WHITE); Typeface font = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD); paint.setTypeface( font ); paint.setTextSkewX(-0.5f); //float类型参数,负数表示右斜,整数左斜 canvas.drawText(str, 10, fontSize + 5, paint); }