修复 CoordinatorLayout 中的底栏 [英] Fix bottom bar in CoordinatorLayout

查看:31
本文介绍了修复 CoordinatorLayout 中的底栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 AppBarLayoutCoordinatorLayout 和一个包含片段的 FrameLayout.

I have a CoordinatorLayout which contains AppBarLayout and a FrameLayout which contains fragments.

这个片段的一个在顶部包含一个 TabLayout,一个 List 槽 RecyclerView 和在底部一个自制"工具栏.

One of this fragment contains a TabLayout at Top, one List trough RecyclerView and at the Bottom one "homemade" toolbar.

AppBarLayout 配置了 app:layout_scrollFlags="scroll|enterAlways"

我的问题是滚动时两个工具栏"都隐藏了,AppBarLayout 和我的自制"工具栏在底部.这是当前的行为

My problem is that both "toolbars" are hiding when scroll, the AppBarLayout and my "homemade" toolbar at the bottom. This is the current behaviour

我想修复底部的自制"工具栏以保持可见,但我无法实现.

I would like to fix the bottom "homemade" toolbar to keep visible but I can't achieve it.

这是片段布局的XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    >
    <android.support.design.widget.TabLayout
        android:id="@+id/toolbarfilter"
        android:layout_width="match_parent"
        android:background="@color/azul_asde"
        app:tabMode="fixed"
        app:tabMaxWidth="0dp"
        android:elevation="4dp"
        app:tabIndicatorColor="@color/verde_pastel"
        android:layout_height="wrap_content"
        />

    <android.support.v4.widget.SwipeRefreshLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/swipeContainer"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

    <android.support.v7.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
    </android.support.v4.widget.SwipeRefreshLayout>

        <LinearLayout
        android:id="@+id/toolbarselection"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:background="@color/azul_asde"
        android:elevation="4dp"
        android:visibility="visible"
        >
        <ImageView
            android:id="@+id/delete"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_delete_white_24dp"
            android:tint="@color/gris_desactivado" />
        <ImageView
            android:id="@+id/select"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_bookmark_border_white_24dp"/>

        <ImageView
            android:id="@+id/send"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:src="@drawable/ic_send_white_24dp"
            android:tint="@color/gris_desactivado" />

    </LinearLayout>

</LinearLayout>

这个 问题似乎是同一个问题.

THIS questions seems to be the same problem.

推荐答案

试试这个布局:

<?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:id="@+id/container">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_margin="10dp"
            android:layout_height="110dp"
            android:padding="15dp"
            card_view:cardElevation="2dp"
            card_view:cardCornerRadius="4dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Test" />

        </android.support.v7.widget.CardView>


        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:id="@+id/card_view1"
            android:layout_width="match_parent"
            android:layout_margin="10dp"
            android:layout_height="110dp"
            android:padding="15dp"
            card_view:cardElevation="2dp"
            card_view:cardCornerRadius="4dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Test" />

        </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:id="@+id/card_view3"
                android:layout_width="match_parent"
                android:layout_margin="10dp"
                android:layout_height="110dp"
                android:padding="15dp"
                card_view:cardElevation="2dp"
                card_view:cardCornerRadius="4dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Test" />

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:id="@+id/card_view4"
                android:layout_width="match_parent"
                android:layout_margin="10dp"
                android:layout_height="110dp"
                android:padding="15dp"
                card_view:cardElevation="2dp"
                card_view:cardCornerRadius="4dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Test" />

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:id="@+id/card_view5"
                android:layout_width="match_parent"
                android:layout_margin="10dp"
                android:layout_height="110dp"
                android:padding="15dp"
                card_view:cardElevation="2dp"
                card_view:cardCornerRadius="4dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="Test" />

            </android.support.v7.widget.CardView>
        </LinearLayout>
    </ScrollView>


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:gravity="bottom">

        <android.support.design.widget.BottomNavigationView
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_weight="1"
            android:foregroundGravity="bottom"
            android:background="@color/green"
            app:itemIconTint="@color/white"
            app:itemTextColor="@color/white"
            android:id="@+id/bottomnav"
            app:menu="@menu/main">


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

    </RelativeLayout>



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

这篇关于修复 CoordinatorLayout 中的底栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆