Place the navigation bar at the bottom of the screen in the Android app

I want to place the navigation bar at the bottom of the screen in an Android application. How can i do this? Sample code would be helpful.

+3
source share
1 answer

If you use RelativeLayout to root your activity, you can align other views at the bottom of the screen. This, combined with LinearLayout as a container, will provide a flexible bar to host your navigation bar:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:orientation="horizontal">

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/back" 
        android:text="Back"
        android:layout_width="wrap_content" />

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/home" 
        android:text="Home" 
        android:layout_width="wrap_content" />

        <Button 
        android:layout_height="wrap_content" 
        android:id="@+id/next" 
        android:text="Next" 
        android:layout_width="wrap_content" />

    </LinearLayout>

</RelativeLayout>
+4
source

Source: https://habr.com/ru/post/1735197/


All Articles