简体   繁体   中英

how can I add text under every icon in bottom navigation

I am using meowBottomNavigation library for customized bottom navigation but I can't add Text under each icon. is there any way to add text under each icon? Following is my XML layout

<com.etebarian.meowbottomnavigation.MeowBottomNavigation
    android:id="@+id/nav_view"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="0dp"
    android:layout_marginStart="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:mbn_circleColor="#E96749AA"
    app:mbn_selectedIconColor="@color/white"
    app:mbn_countTextColor="@color/white"
    app:mbn_countBackgroundColor="#ff6f00"
    app:mbn_defaultIconColor="@color/white"
    app:mbn_backgroundBottomColor="#272626"/>

Disclaimer: I might be wrong, because I haven't heard of this library before

By taking a look at the MeowBottomNavigation.Model class, you will notice that it does not contain any "description text":

 val params = LinearLayout.LayoutParams(0, heightCell, 1f)
            layoutParams = params
            icon = model.icon
            count = model.count
            defaultIconColor = this@MeowBottomNavigation.defaultIconColor
            selectedIconColor = this@MeowBottomNavigation.selectedIconColor
            circleColor = this@MeowBottomNavigation.circleColor
            countTextColor = this@MeowBottomNavigation.countTextColor
            countBackgroundColor = this@MeowBottomNavigation.countBackgroundColor
            countTypeface = this@MeowBottomNavigation.countTypeface
            rippleColor = this@MeowBottomNavigation.rippleColor

or anything similar to that, also, by looking at the preview: 从库 github 页面预览

you can notice that even fitting the description in that navigation bar would be quite challenging, so I believe with this library it is not possible. (However I am not sure why one would use that library. Building a navigation bar like that wouldn't take long and it would be easier to modify/implement new features to it, also it would not require changes to "settings.gradle" (had to add "jcenter()" which is a repository that no longer receives updates))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM