Android 静态布局字体大小
有没有办法改变静态布局的字体大小?这是我到目前为止要展示的 文本位于正确的开头位置。
int question_text_width = game_question_bg.getWidth();
int question_text_xPos = 100;
int question_text_yPos = 100;
StaticLayout question_text = new StaticLayout(text, text_paint, question_text_width, Layout.Alignment.ALIGN_CENTER, 1.2f, 1.0f, false);
//Position Text
canvas.translate(question_text_xPos, question_text_yPos);
//As a form of setMaxLine
canvas.clipRect(new Rect(0, 0, game_question_bg.getWidth(), game_question_bg.getHeight()));
question_text.draw(canvas);
//Reset canvas back to normal
canvas.restore();
Is there anyway to change the font size of a static layout? This what I have so far to display the
text in the correct place to begin with.
int question_text_width = game_question_bg.getWidth();
int question_text_xPos = 100;
int question_text_yPos = 100;
StaticLayout question_text = new StaticLayout(text, text_paint, question_text_width, Layout.Alignment.ALIGN_CENTER, 1.2f, 1.0f, false);
//Position Text
canvas.translate(question_text_xPos, question_text_yPos);
//As a form of setMaxLine
canvas.clipRect(new Rect(0, 0, game_question_bg.getWidth(), game_question_bg.getHeight()));
question_text.draw(canvas);
//Reset canvas back to normal
canvas.restore();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用创建 StaticLayout 时作为参数传递的 TextPaint 设置字体大小:
You can set the font size using the TextPaint you pass as an argument when the StaticLayout is created: