Как добавить вид снизу в макет координатора с помощью пейджера?

Я хочу добавить вид снизу к макету Coordinator с view pager в нем, вид снизу будет поверх fragment, загруженного view pager, и не зависит от него.

Я добавил linear layout с

layout_gravity = "bottom"

но вид снизу linear layout вообще не отображается

Ниже приведен мой макет xml для activity.

<android.support.design.widget.CoordinatorLayout

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/maintoolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    <android.support.design.widget.TabLayout
        android:id="@+id/maintabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="fixed"
        app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>





<android.support.v4.view.ViewPager
    android:id="@+id/mainviewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"  />


<LinearLayout
    android:id="@+id/completeBottomView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ProgressBar
        android:id="@+id/progressBarBottomView"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:indeterminate="false"
        android:visibility="gone"
        android:max="100"
        android:progress="1"/>

    <HorizontalScrollView
        android:id="@+id/limiter_scroller"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|start"
        android:background="#FF3399"
        >
        <LinearLayout
            android:id="@+id/limiter_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:onClick="clickFromBottomView"/>
    </HorizontalScrollView>

</LinearLayout>

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

person Devansh Kumar    schedule 16.03.2016    source источник
comment
добавить completeBottomView внутрь framelayout попробовать   -  person Dhaval Parmar    schedule 17.03.2016


Ответы (3)


Как указано в комментарии @Dhawal .... Решение состоит в том, чтобы обернуть LinearLayout completeBottomView в FrameLayout с android:layout_gravity="bottom"

person Devansh Kumar    schedule 20.03.2016
comment
это исправило мою проблему. внизу был прикреплен текст редактирования, который мне нужен, чтобы появиться на клавиатуре, когда он получил фокус. ваше здоровье - person filthy_wizard; 12.07.2016
comment
Добавление android:layout_gravity="bottom" непосредственно в ваш LinearLayout (completeBottomView) также должно работать. Я не думаю, что дополнительный FrameLayout необходим - person O'Kamiye; 30.12.2016
comment
Разве это не означает, что содержимое нижнего вида будет перекрывать другое содержимое? - person android developer; 23.04.2017
comment
Любое решение? Нижний вид покрывает часть содержимого моего viewPager - person saintjab; 30.05.2019
comment
Не решение, особенно если вам нужна полупрозрачная полоса с fitsSystemWindows - person Mihae Kheel; 08.04.2021

Поведение нижнего макета Android CoordinatorLayout.

activity_bottom.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimaryDark"
            app:layout_scrollFlags="scroll|enterAlways"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#C0C0C0"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.example.android.coordinatedeffort.widget.FooterBarLayout
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#007432"
            android:gravity="center"
            android:text="Footer View"
            android:textColor="@android:color/white"
            android:textSize="25sp" />
    </com.example.android.coordinatedeffort.widget.FooterBarLayout>

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

FooterBarLayout.java

FooterBarBehavior.java

person Ahamadullah Saikat    schedule 19.07.2018

Этот код работал для меня. Измените атрибут app:layout_scrollFlags="scroll|enterAlways" на app:layout_scrollFlags="scroll" в android.support.v7.widget.Toolbar. Подробнее здесь

person Hisham    schedule 25.05.2017