简体   繁体   English

在Android Studio中预览自定义字体

[英]Preview custom fonts in Android Studio

Currently I'm using the pixlui library to use custom fonts, and it's great! 目前我正在使用pixlui库来使用自定义字体,这太棒了! https://github.com/neopixl/PixlUI https://github.com/neopixl/PixlUI

Is there any way to preview the custom fonts in Android Studio? 有没有办法在Android Studio中预览自定义字体?

I have created a Library called Smart Fonts for Android. 我创建了一个名为Smart Fonts for Android的库。 It allows you to preview the custom fonts in the Layout Editor of Android Studio. 它允许您 Android Studio 的布局编辑器预览自定义字体

The fonts are cached in memory so that they are loaded once. 字体缓存在内存中,以便加载一次。

Smart Fonts is easy to integrate with gradle, it is documented and available on GitHub: 智能字体很容易与gradle集成,它在GitHub上有记录并可用:

https://github.com/smart-fun/SmartFonts https://github.com/smart-fun/SmartFonts

enjoy! 请享用!

Unfortunately no. 抱歉不行。 The way that PixelUI is setting the font doesn't work in the previewer. PixelUI设置字体的方式在预览器中不起作用。

They are only setting font in one constructor as is visible here: https://github.com/neopixl/PixlUI/blob/master/Library/src/com/neopixl/pixlui/components/textview/TextView.java 它们只在一个构造函数中设置字体,如下所示: https//github.com/neopixl/PixlUI/blob/master/Library/src/com/neopixl/pixlui/components/textview/TextView.java

The constructor the editor is using is the second one, and the font is not set when the TextView is constructed this way. 编辑器正在使用的构造函数是第二个,并且在以这种方式构造TextView时不会设置字体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM