Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一个 android 应用程序,只需按一下按钮即可更改字体。我在 Google 上搜索过 stackoverflow 和其他网站,但空手而归。我正在使用 Eclipse。目标是能够简单地触摸一个显示“times new roman”的按钮,然后将上面的文本更改为该字体。我发现有人试图更改 Eclipse 中的字体,或者只是他们应用程序的默认字体,但用户无法更改它。在找到一个改变背景颜色的应用程序后,我有了这个想法。有谁知道按钮需要什么代码?
字体是您正在寻找的。
在按钮的onclicklistener中,尝试类似
TextView txt=(TextView)findViewById(...); Typeface tf=Typeface.createFromAsset(...); txt.setTypeface(tf);