BottomNavigationView应该看起来像Youtube应用程序

问题描述 投票:0回答:1

我想像YouTube一样创建一个BottomNavigationView屏幕,但我面临的问题是视图没有像那样显示。

它完全适用于三个底部菜单,但当我使用三个以上的菜单时,它的标题隐藏,菜单被移动。我不明白为什么会这样,我尝试了许多技巧但没有解决问题。

enter image description here

enter image description here

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="?android:attr/windowBackground"
    app:menu="@menu/navigation" />

Java活动:

BottomNavigationView navigation = findViewById(R.id.navigation);

// I had tried this code but not working

//   BottomNavigationMenuView menuView = (BottomNavigationMenuView) 
//   bottomNavigationView.getChildAt(0);
//            bottomNavigationView.setAnimation(null);
//            for (int i = 0; i < menuView.getChildCount(); i++) {
//                BottomNavigationItemView itemView = (BottomNavigationItemView) menuView.getChildAt(i);
//                itemView.setShiftingMode(false);
//                itemView.setChecked(false);
//            }
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

任何人,请建议我如何实现这一目标。

android bottomnavigationview
1个回答
0
投票

默认情况下,android仅使选定的项目标题出现在三个以上的菜单项上。如果您不希望发生这种情况,请将BottomNavigationView XML属性app:labelVisibility设置为已标记。

© www.soinside.com 2019 - 2024. All rights reserved.