如何在Android TextView中设置字体宽度? [英] How to set font width in an Android textview?

查看:962
本文介绍了如何在Android TextView中设置字体宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,用于显示对字体宽度非常敏感的信息(例如ASCII艺术).我一直在使用等宽字体,但是它不能很好地工作,因为信息中包含宽字符(例如中文和日文字符),并且textview不能使宽字符的宽度正好是普通字符的两倍.因此,我试图查看是否可以更改文本视图中字体的宽度,或者是否有解决此问题的更好方法?在我的应用程序中安装其他等宽字体是个好主意吗?任何输入,不胜感激.谢谢.

I am developing an app that displays information such as ascii arts which are very sensitive to font width. I've been using monospace font, but it does not work well because there are wide chars (such as Chinese and Japanese characters) in the information and the textview does not make the wide chars exactly twice wide as regular chars. Therefore I am trying to see if it's possible to alter the width of fonts in a textview, or if there's better way to solve this problem? Is Installing another monospace font to my app a good idea? Any input is greatly appreciated. Thank you.

凯文

推荐答案

您可以尝试

textView.setTextScaleX(1.5f);

textView.setTextSize(20);

textView.setTypeface(Typeface.MONOSPACE);    //all characters the same width

希望通过这三种方法可以将字体设置为所需的外观.

With these three methods I hope you can set the font to a desirable appearance.

这篇关于如何在Android TextView中设置字体宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆