Reputation: 17
i am trying to use androidx BottomNavigationView in one activity with 3 fragment to navigate between those fragments , but the icons and titles are not showing .
i have tried many answers for the same questionand setting the labelVisibilityMode to labled but nothing worked
activity layout
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Sorting_activity">
<RelativeLayout
android:id="@+id/triLayout"
android:layout_width="0dp"
android:layout_height="300dp"
app:layout_constraintBottom_toTopOf="@+id/stepsLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
</RelativeLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/stepsLayout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/buttomLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/triLayout"
>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/buttomLayout"
android:layout_width="match_parent"
android:layout_height="49dp"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="682dp"
>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cardview_shadow_start_color"
app:menu="@menu/buttom_navigation"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="682dp"
app:labelVisibilityMode="labeled"
app:itemIconTint="@color/colorAccent"
app:itemTextColor="@color/colorPrimary"/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
menu
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/nav_theory"
android:icon="@drawable/ic_baseline_theory_24"
android:title="@string/bottom_navigation_menu_theory" />
<item
android:id="@+id/nav_steps"
android:icon="@drawable/ic_baseline_sort_24"
android:title="@string/bottom_navigation_menu_steps"
/>
<item
android:id="@+id/nav_code"
android:icon="@drawable/ic_baseline_code_24"
android:title="@string/bottom_navigation_menu_code" />
</menu>
Upvotes: 0
Views: 777
Reputation: 1
If u can't see ur icons try add this:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
app:labelVisibilityMode="labeled"
android:visibility="visible"
app:itemBackground="#ffffff"
app:itemTextColor="#ffffff"
app:itemIconTint="#ffffff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/menu_navegacion" />
Upvotes: 0
Reputation: 4156
Try to clean project and rebuild and Try this way it works on mine
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/stepsLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
app:labelVisibilityMode="labeled"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Upvotes: 4