BottomNavigationView的自定义TextSize支持android [英] Custom TextSize of BottomNavigationView support android

查看:298
本文介绍了BottomNavigationView的自定义TextSize支持android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从android支持库25.0.0更改BottomNavigationView的textSize

I am trying to change the textSize of BottomNavigationView from android support library 25.0.0

<android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimaryDark"
        android:foregroundTint="@color/colorAccent"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"
        app:layout_anchor="@id/lyt_container"
        app:layout_anchorGravity="bottom"
        app:itemTextAppearance="@style/TextStyleBNV"
        app:menu="@menu/nav_menu" />

<style name="TextStyleBNV">
        <item name="android:textSize">@dimen/twelve_sp</item>
        <item name="android:padding">0dp</item>
        <item name="textAllCaps">false</item>
    </style>

有什么我想念的吗?

推荐答案

不幸的是,BottomNavigationView的第一个版本存在很多限制.现在,您不能仅使用支持设计API来更改标题大小.因此,要在Google未实现此限制的情况下解决此限制,您可以执行以下操作:

Unfortunately this first version of BottomNavigationView came with a lot of limitations. And for now you can't change titles size just using the support design API. So to solve this limitation while google doesn't implement it, you can do:

在您的dimen.xml中,您可以输入:

In your dimen.xml you can put:

    <dimen name="design_bottom_navigation_text_size" tools:override="true">30sp</dimen>
    <dimen name="design_bottom_navigation_active_text_size" tools:override="true">30sp</dimen>

这样做,您将覆盖BottomNavigationView内部类使用的dimen的默认值.所以要小心.

Doing this you are overriding the default value of dimen that the internal classes of BottomNavigationView use. So be carreful.

这篇关于BottomNavigationView的自定义TextSize支持android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆