zoukankan      html  css  js  c++  java
  • BottomNavigationView3个项以上不显示文字的问题

    1、xml

    <!--app:labelVisibilityMode="labeled"  -->
    <com.google.android.material.bottomnavigation.BottomNavigationView
                android:id="@+id/bottom_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:background="@android:color/white"
                app:labelVisibilityMode="labeled"  
                app:layout_behavior=".utils.BottomNavigationBehavior"
                design:menu="@menu/tab_menu" />

    2、java

    //onCreate中
    viewDataBinding.bottomView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);

    3、底部组建切换

            viewDataBinding.bottomView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
                    Fragment fragment = null;
                    switch (menuItem.getItemId()) {
                        case R.id.menu:
                              fragment = mHomeFragment;
                              break;
                    }
                    if (getSupportActionBar() != null) {
                        getSupportActionBar().setTitle(menuItem.getTitle());//如果toolbar不为空,将title换掉
                    }
                    switchFragment(fromFragment, fragment);
                    fromFragment = fragment;
                    return true;           //如果返回为false,则切换底部按钮颜色不会切换
                }
            });
  • 相关阅读:
    ID,ClientID,UniqueID的区别
    Struct构造函数
    关于sizeof,typeof
    C#文件读写
    code1
    .NET中加密与解密QueryString的方法
    addEventListener和attachEvent的区别
    执行带参数的存储过程
    如何得到机器上装的Powershell的版本
    [Gradle] How to determine OS info
  • 原文地址:https://www.cnblogs.com/anny0920/p/12887306.html
Copyright © 2011-2022 走看看