web-dev-qa-db-ja.com

下部のナビゲーションバーでアイテムのタイトルを非表示にする必要があります

下部のナビゲーションバーを作成し、タイトルを非表示にしてアイコンのみを表示する必要がありますが、空の文字列でタイトルを書くと、アイコンと下部の間に大きなスペースがあり、文字列を空の文字列に置き換えるだけで、多くの検索を行いますが、解決策が見つかりませんだからどんな助けでも

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:app="http://schemas.Android.com/apk/res-auto"
xmlns:tools="http://schemas.Android.com/tools"
Android:id="@+id/container"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
tools:context="com.easyschools.student.HomeActivity">

<FrameLayout
    Android:id="@+id/main_container"
    Android:layout_width="match_parent"
    Android:layout_height="match_parent"
    Android:layout_above="@+id/navigation"
    Android:layout_alignParentTop="true">
 </FrameLayout>

<Android.support.design.widget.BottomNavigationView
    Android:id="@+id/navigation"
    Android:layout_width="match_parent"
    Android:layout_height="wrap_content"
    Android:layout_marginEnd="0dp"
    Android:layout_marginStart="0dp"
    Android:background="@Android:color/white"
    Android:layout_alignParentBottom="true"
    app:menu="@menu/navigation"/>

</RelativeLayout>

navigation.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:app="http://schemas.Android.com/apk/res-auto">

    <item
        Android:id="@+id/nav_messages"
        Android:icon="@drawable/msg_icon"
        Android:title=""/>

    <item
        Android:id="@+id/nav_home"
        Android:icon="@drawable/home_icon"
        Android:title=""
        Android:checked="true"/>

    <item
        Android:id="@+id/nav_notify"
        Android:icon="@drawable/notify_icon"
        Android:title=""/>

    <item
        Android:id="@+id/nav_my_profile"
        Android:icon="@drawable/user_icon"
        Android:title=""/>
</menu>
7
Maysa Khamis

サポートライブラリから開始28.0.0-alpha1、次を使用できます:

app:labelVisibilityMode="unlabeled"

タイトルを非表示にし、

app:itemHorizontalTranslationEnabled="false"

追加:

xmlns:app="http://schemas.Android.com/apk/res-auto"

xmlでBottomNavigationViewへのシフトモードを無効にするには

8

BottomNavigationViewには多くの制限があります。

たとえば、空のString""でタイトルを設定できますが、下部のナビゲーションバーを簡単に拡張するためにライブラリを使用することをお勧めします。

これを試すことができます: https://github.com/ittianyu/BottomNavigationViewEx

0
Jéwôm'