gpt4 book ai didi

android - ActionBar setIcon with Font-Awesome

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:02:48 24 4
gpt4 key购买 nike

是否可以通过使用 AwesomeFont 的 "Text" setIcon 方法(接受 drawable 或 Resource id)在 ActionBar 中设置一个图标?

我应该创建一个 Drawable 还是类似的东西?在 Drawable 中我应该创建什么?

编辑

public class AwesomeTextView extends TextView {

private static Typeface fontAwesome;

public AwesomeTextView(Context context, AttributeSet attrs) {
super(context, attrs);

if (fontAwesome == null) {
fontAwesome = Typeface.createFromAsset(context.getAssets(), "fonts/fontawesome-webfont.ttf");
}

setTypeface(fontAwesome);
}

}

所以我创建了一个使用 font-awesome 的 AwesomeTextView,有没有办法让 AwesomeTextView 可绘制?

最佳答案

我做了一个 repo 来轻松地为你的 android 项目添加 Font Awesome 图标

https://github.com/bperin/FontAwesomeAndroid

如果您尝试将这些添加到操作栏中,您可能需要通过 XML 制作自定义布局

关于android - ActionBar setIcon with Font-Awesome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18074919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com