I have Bottom Navigation View at the bottom and i want to make it swipeable. is there any way to make them swipeable?
here is how it looks
here is xml file
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/maincolor"
tools:context=".MainActivity">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/nav_items"
app:itemIconTint="@color/color"
android:background="@color/secondarycolor"
app:itemRippleColor="@color/white"
app:labelVisibilityMode="labeled"
app:itemTextColor="@color/color"
>
</com.google.android.material.bottomnavigation.BottomNavigationView>
</RelativeLayout>
Here is menu file which contains all the menu bar items
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/home_btn"
android:icon="@drawable/ic_home"
android:title="@string/home"
/>
<item android:id="@+id/search_btn"
android:icon="@drawable/ic_search"
android:title="@string/search"
/>
<item android:id="@+id/playlist_btn"
android:icon="@drawable/ic_playlist"
android:title="@string/playlists"
/>
<item android:id="@+id/settings_btn"
android:icon="@drawable/ic_settings"
android:title="@string/settings"
/>
</menu>
My Mainactivity.java file is default one
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
You can use immersive mode, check this
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}