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>
また、次のコードも記述します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>
ご協力いただければ幸いです。
前もって感謝します!
ベストアンサー1
フォントをリソースとしてバンドルするには、res/font/ フォルダにフォントファイルを追加します。
それから
スタイル リソースを使用して変更できます。styles.xml で次の操作を行います。
<style name="Widget.BottomNavigationView"
parent="Widget.Design.BottomNavigationView">
<item name="fontFamily">@font/your_font</item>
</style>
次に、それをビューのテーマとして適用します。
<android.support.design.widget.BottomNavigationView
...
android:theme="@style/Widget.BottomNavigationView"
/>
アプリで確認したところ、問題なく動作しています。
参照:https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml.html#fonts-in-code