【发布时间】:2018-03-17 03:07:53
【问题描述】:
我是 android 的初学者。我正在为图标使用 font-awesome 库。我想使用 view pager 在tablyout 中使用 font-awesome 设置图标
【问题讨论】:
-
你能发布你的代码吗?
标签: android font-awesome android-tablayout
我是 android 的初学者。我正在为图标使用 font-awesome 库。我想使用 view pager 在tablyout 中使用 font-awesome 设置图标
【问题讨论】:
标签: android font-awesome android-tablayout
创建一个名为 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("");
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/fontawesome-webfont.ttf");
tabOne.setTypeface(typeface);
tabLayout.getTabAt(0).setCustomView(tabOne);
【讨论】: