
我为我的应用程序使用底部导航视图,并希望删除图标下的文本.我在互联网上寻找它,但仍然找不到解决方案.有没有人用来解决这个问题,请给我您的解决方案.
我想要的是这样的:
我的代码在这里:
主要布局包含一个recyclervIEw和bottomnavigationvIEw:
<linearLayout androID:weightSum="10" androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"> <androID.support.v7.Widget.RecyclerVIEw androID:layout_margintop="20dp" androID:layout_weight="8.5" androID:ID="@+ID/recyclervIEw_menu" androID:layout_wIDth="match_parent" androID:layout_height="0dp"> </androID.support.v7.Widget.RecyclerVIEw> <androID.support.design.Widget.BottomNavigationVIEw androID:background="@color/whitecolor" androID:ID="@+ID/bottom_navigation_bar" androID:layout_weight="1.5" app:menu="@menu/menu_bottom_navigation" androID:layout_wIDth="match_parent" androID:layout_height="0dp"> </androID.support.design.Widget.BottomNavigationVIEw></linearLayout>这是底部导航菜单:
<menu xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:app="http://schemas.androID.com/apk/res-auto"><item androID:ID="@+ID/action_favorites" androID:enabled="true" androID:icon="@drawable/ic_search" androID:title="Home" app:showAsAction="ifRoom" /><item androID:ID="@+ID/action_schedules" androID:enabled="true" androID:icon="@drawable/ic_search" androID:title="Search" app:showAsAction="ifRoom" /><item androID:ID="@+ID/action_music" androID:enabled="true" androID:icon="@drawable/ic_search" androID:title="Save" app:showAsAction="ifRoom" /><item androID:ID="@+ID/action_me" androID:enabled="true" androID:icon="@drawable/ic_search" androID:title="Me" app:showAsAction="ifRoom" />在MainActivity中:
mBottombar = (BottomNavigationVIEw) findVIEwByID(R.ID.bottom_navigation_bar); disableShiftMode(mBottombar); public voID disableShiftMode(BottomNavigationVIEw vIEw) { BottomNavigationMenuVIEw menuVIEw = (BottomNavigationMenuVIEw) vIEw.getChildAt(0); try { FIEld shiftingMode = menuVIEw.getClass().getDeclaredFIEld("mShiftingMode"); shiftingMode.setAccessible(true); shiftingMode.setBoolean(menuVIEw, false); shiftingMode.setAccessible(false); for (int i = 0; i < menuVIEw.getChildCount(); i++) { BottomNavigationItemVIEw item = (BottomNavigationItemVIEw) menuVIEw.getChildAt(i); item.setShiftingMode(false); // set once again checked value, so vIEw will be updated item.setChecked(item.getItemData().isChecked()); } } catch (NoSuchFIEldException e) { Log.e("Luan", "Unable to get shift mode fIEld"); } catch (illegalaccessexception e) { Log.e("Luan", "Unable to change value of shift mode"); }}解决方法:
将“ app:labelVisibilityMode”设置为“ unlabeled”
<androID.support.design.Widget.BottomNavigationVIEw androID:ID="@+ID/navigation" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" app:labelVisibilityMode="unlabeled"/> 总结 以上是内存溢出为你收集整理的在Android中删除底部导航视图文本全部内容,希望文章能够帮你解决在Android中删除底部导航视图文本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)