如何使用 fontawesome 设置 tablayout 图标

how to set tablayout icon using fontawesome

我是 android.I 的初学者,我正在使用字体超棒的图标库。我想使用 view pager

tablyout 中使用 font-awesome 设置图标

创建一个名为 custom_tab.xml 的 xml 布局

custom_tab.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tab"
    />

现在使用下面的代码设置选项卡布局的字体

TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabOne.setText("&#xf1fe;");
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/fontawesome-webfont.ttf");
tabOne.setTypeface(typeface);
tabLayout.getTabAt(0).setCustomView(tabOne);

How to Use FontAwesome in an Android App