I have an activity, where i setup the Bottom Navigation View and appCompat toolbar. And I write the code like this.
But due to this, my toolbar shown like this. which i don't want.
How can i hide the fragment name from my toolbar?
CodePudding user response:
Try using a menu for the bottomNavigation items instead
Create a menu_item.xml in your res/menu The code:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@ id/home"
android:enabled="true"
android:title="Home" />
<item
android:id="@ id/account”
android:title="Account" />
<item
android:id="@ id/more_Fragment"
android:title =“ ”
/>
</menu>
You can then set the title to be displayed or leave it empty which solves your problem
Then you assign the menu to the bottomnavbar xml like this :
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@ id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
app:itemIconTint="@android:color/black"
app:itemTextColor="@android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="1.0"
app:menu="@menu/menu_item" />
CodePudding user response:
I simply hide title by using the following code.
supportActionBar?.let { it ->
it.title = ""
}