我有Spannable对象,我想通过我之前加载的自定义字体设置其字体.
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/font_Name.ttf");
Spannable span1 = /*Spannable Item*/;
/// I want to set span1 to have tf font face???
/// Here where I want help.
Run Code Online (Sandbox Code Playgroud)
编辑:
我的问题是我想为文本视图设置两种不同的自定义字体,所以我正在使用Spannable
我在我的android页面中创建了一个底栏导航.但现在我想在底部导航文本中应用自定义字体系列.
这是.xml文件中的底部导航代码:
<android.support.design.widget.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bottomNavView_Bar"
android:background="@drawable/white_grey_border_top"
app:menu="@menu/bottom_navigation_menu">
</android.support.design.widget.BottomNavigationView>
Run Code Online (Sandbox Code Playgroud)
此外,代码bottom_navigation_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<item
android:id="@+id/ic_newsfeed"
android:icon="@drawable/ic_menu_camera"
android:title="NEWSFEED"
/>
<item
android:id="@+id/ic_explorer"
android:icon="@drawable/ic_home_black_24dp"
android:title="EXPLORER"
/>
<item
android:id="@+id/ic_notify"
android:icon="@drawable/ic_notifications_black_24dp"
android:title="NOTIFY"
/>
<item
android:id="@+id/ic_more"
android:icon="@drawable/ic_dashboard_black_24dp"
android:title="MORE"
/>
</menu>
Run Code Online (Sandbox Code Playgroud)
帮助将不胜感激.
提前致谢!