【发布时间】:2016-05-04 09:59:08
【问题描述】:
我最近在使用多色字体时遇到了一些麻烦。我使用的字体使用了白色和黑色,但由于某种原因,只显示了黑色,而内部的白色没有显示。我做错了什么,或者有没有办法让字体颜色在那里?谢谢你。这是代码--
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/editundo.otf");
//crating color fill and adding in font to the paint and setting the color fill white and text size 150
Paint paint = new Paint();
paint.setTypeface(tf);
paint.setTextSize(150);
// do other setup on Paint object
// Draw all the text stuff
//if the screen has not been tapped touch screen to start
if (f == 0) {
canvas.drawText("Tap to Start", MainActivity.screenWidth / 4, MainActivity.screenHeight / 2, paint);
}
//Setting text as 40 size and draw the score text
paint.setTextSize(40);
canvas.drawText("Score: " + score, 10, 50, paint);
canvas.drawText("High Score: " + HighScore, 10, 120, paint);
paint.setTextSize(35);
canvas.drawText("Car Tokens: " + coinz, MainActivity.screenWidth*7/9+MainActivity.screenWidth*2/100, 50, paint);
另外,我使用的字体是 Mouser Outline 字体,我将它用作 .otf 和 .ttf。字体的链接在这里——http://fontzone.net/font-details/mouser-outline
再次感谢您的帮助。
【问题讨论】:
-
您需要做的就是在您的绘画对象上设置颜色:
paint.setColor(Color.WHITE) -
我试过了。它没有用,我也想要内部是白色的。