androidlayoutfragmentandroid-linearlayoutandroid-coordinatorlayout

Linearlayout not taking place over fragment


I have this layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
tools:context="ca.usherbrooke.whapl.MainActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:elevation="4dp"/>

</android.support.design.widget.AppBarLayout>


<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:orientation="horizontal"
        android:paddingTop="5dp"
        android:paddingBottom="10dp"
        android:background="@color/colorPrimary"
        >

        <ImageView
            android:id="@+id/previous"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_action_previous"/>

        <ImageView
            android:id="@+id/play_pause"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_action_play"/>

        <ImageView
            android:id="@+id/next"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_action_next"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:orientation="horizontal"
        android:paddingBottom="10dp"
        android:background="@color/colorPrimary"
        >

        <TextView
            android:layout_marginLeft="10dp"
            android:id="@+id/songname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/white"
            />
    </LinearLayout>

</LinearLayout>

</android.support.design.widget.CoordinatorLayout>

and when I have a ListView in my fragment_container, the player with play/pause/next/rewind button is always over the container, so I cannot access the last element in the list view, because it's behind my player (the linear layout after the fragment_container).

What should I change for the container to only take the place it has and to not go under my player?

By the way this layout is included in the layout of my main activity, which is a DrawerLayout that contain my container + a NavigationView.


Solution

  • Add a android:layout_marginBottom property to the container equal to the height of the player.