Is there any way to prevent the bottom navigation bar from moving during rotation?

Viewed 47

Im trying to get my bottom navigation bar to be fixed on a side of the screen. Let me use pictures to help you understand what I am hoping to achieve.

How the navigation bar looks when in Portrait and Landscape

As you can see, I am trying to achieve the navigation bar to stay in its same position (i.e. top when in portrait but changed to left in landscape), and the icon buttons in the navigation should be rotated. I remember seeing certain apps do this before but I am unsure... Any help appreciated.

This is the XML code of my navigation bar.

<com.google.android.material.bottomnavigation.BottomNavigationView
                android:id="@+id/nav_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/transparent"
                app:elevation="0dp"
                app:itemBackground="@color/transparent"
                app:itemIconTint="@drawable/selector"
                app:itemTextColor="@drawable/selector"
                app:labelVisibilityMode="labeled"
                app:menu="@menu/nav_menu">

            </com.google.android.material.bottomnavigation.BottomNavigationView>
1 Answers

add this to your manifest file:

<activity
 android:name=".whatevernameisyourActivity"
 android:screenOrientation="portrait"
 tools:ignore="LockedOrientationActivity" />

this will force the app not to rotate.

Related