Android的,如何显示在布局编辑模式字体真棒图标? [英] Android, how to display font awesome icons in layout edit mode?

查看:151
本文介绍了Android的,如何显示在布局编辑模式字体真棒图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想字体真棒图标添加到我的Andr​​oid应用程序,我发现了一个解决方案,在这里:

I'm trying to add font awesome icons into my Android App, i found a solution here:

http://stackoverflow.com/a/15762875/535556

但它唯一的应用程序的编译后显示图标和设备上运行。

But it display icons only after compilation of app and run on device.

在这之后,我发现这个插件:

After that i found this plugin:

https://github.com/bperin/FontAwesomeAndroid

不过,这并不为我工作。

But it does not work for me..

我想在版面中直接显示的字体真棒图标,因为难道是编译应用程序来检查快得多正确显示。

I would like to display font awesome icons directly in layout because is it much faster that compile application to check that is displayed correctly.

任何意见非常感谢。

推荐答案

请确保您的TTF是/src/main/assets/font/fontawesome.ttf(或者它的命名,确保它的全部小写虽然)还请确认您的.iml文件的目录的资产匹配的:

Make sure your ttf is in /src/main/assets/font/fontawesome.ttf (or whatever it's named, make sure it's all lower case though) Also verify that in your .iml file the assets directory matches this:

<选项名=ASSETS_FOLDER_RELATIVE_PATHVALUE =/ src目录/主/资产/方式>

一旦全部到位,然后去查看,你会显示图标(而不是XML文件,但java文件),并在onCreate()方法或任何你认为是最好的,使用创建的字体在fo​​ntawesome.ttf并将其分配给您的TextView的图标,按钮,或任何你想要的视觉元素,像这样的:

once that is all in place then go to view where you will be displaying the icon (not the xml file, but the .java file) and in the onCreate() method or whichever you think is best, create a typeface using the fontawesome.ttf and assign it to your icon TextView, Button, or whatever visual element you want, like this:

public static final String FONT_AWESOME_PATH = "fonts/fontawesome.ttf";
private TextView leftEyeEditIcon;

leftEyeEditIcon = (TextView) findViewById(R.id.edit_icon);
leftEyeEditIcon.setTypeface(Typeface.createFromAsset(getResources().getAssets(), FONT_AWESOME_PATH));


可以然后通过进入xml.file和设置TEXTSIZE调整图标的大小,因为这在技术上是一个字体


You can then adjust the size of the icon by going into the xml.file and setting the TextSize, since this is technically a "font".

这篇关于Android的,如何显示在布局编辑模式字体真棒图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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