Reputation: 3759
In TextView, I can use android:letterSpacing="0.1"
to set letter spacing
But this is not work in BottomNavigationView
I use this code to set font style of BottomNavigationView
I guess I can also set letter spacing here, but I cannot find related method
How to set the letter spacing?
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
app:menu="@menu/navigation" >
val font = Typeface.createFromAsset(assets, "UniversNextPro-LightCond.otf")
val typefaceSpan = CustomTypefaceSpan("", font)
navigation.menu.size()
for (i in 0 until navigation.menu.size()) {
val menuItem = navigation.menu.getItem(i)
val spannableTitle = SpannableStringBuilder(menuItem.getTitle())
spannableTitle.setSpan(typefaceSpan, 0, spannableTitle.length, 0)
menuItem.setTitle(spannableTitle)
}
Upvotes: 0
Views: 295
Reputation: 61
I was able to do it in this way:
Widget.Design.BottomNavigationView
<style name="BottomNavigationTheme" parent="Widget.Design.BottomNavigationView">
<item name="android:letterSpacing">0.1</item>
</style>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:theme="@style/BottomNavigationTheme"
app:menu="@menu/navigation" >
Upvotes: 2