Made by FA
Made by FA

Reputation: 728

How to make a bottom bar in Material theme Drawer activity

For my music application, I would like to add a bottom bar which works as the current playback display. As I would like to use one for all fragments, I would just like to add it in the MainActivity. But I'm not sure about how to do it in the layout way. May you help me there?

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:background="@color/sonatic_darker"
android:layout_height="match_parent">

<!-- Framelayout to display Fragments -->
<FrameLayout
    android:id="@+id/frame_container"
    android:fitsSystemWindows="true"
    android:clipToPadding="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<!--
<ListView
    android:id="@+id/list_slidermenu"
    android:fitsSystemWindows="true"
    android:clipToPadding="false"
    android:layout_width="270dp"
    android:layout_height="fill_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector"
    android:background="@drawable/sidebar_background_xml"/> -->

<RelativeLayout
    android:id="@+id/relative_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/sidebar_background_xml"
    android:layout_gravity="start" >

    <ListView
        android:id="@+id/list_slidermenu"
        android:fitsSystemWindows="true"
        android:clipToPadding="false"
        android:layout_width="270dp"
        android:layout_height="fill_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector"
        android:background="@android:color/transparent"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true" >

        <ImageView
            android:id="@+id/profile_image"
            android:layout_width="25dp"
            android:clipToPadding="true"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:layout_alignParentLeft="true"
            android:layout_centerInParent="true"
            android:layout_marginLeft="17dp"
            android:layout_marginRight="24dp"
            android:src="@drawable/ic_sonatic"
            android:layout_centerHorizontal="true" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:clipToPadding="true"
            android:fontFamily="sans-serif-light"
            fontPath="SeraRegular.ttf"
            android:layout_toRightOf="@id/profile_image"
            android:minHeight="?android:attr/listPreferredItemHeightSmall"
            android:textAppearance="?android:attr/textAppearanceListItemSmall"
            android:textColor="@color/list_item_title_selected"
            android:textColorHighlight="@color/list_item_title_selected"
            android:gravity="center_vertical"
            android:textSize="18sp"
            android:text="@string/app_name"
            android:paddingRight="10dp"/>

        <TextView android:id="@+id/counter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:clipToPadding="true"
            android:background="@android:color/transparent"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            fontPath="SeraRegular.ttf"
            android:layout_marginRight="8dp"
            android:textColor="#FFFFFF"/>

    </RelativeLayout>
</RelativeLayout>

Upvotes: 0

Views: 362

Answers (1)

Harin
Harin

Reputation: 2423

Hey follow the below code for drawer layout as per your needs,

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayou
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <FrameLayout
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1" />

            <LinearLayou
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <!--your bottom bar elements-->
            </LinearLayou>

        </LinearLayou>

        <!--your drawer menu-->
        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"></ListView>
</android.support.v4.widget.DrawerLayout>

Upvotes: 1

Related Questions