修复CoordinatorLayout中的底栏

时间:2016-02-23 11:25:41

标签: android android-layout android-toolbar android-coordinatorlayout

我有一个CoordinatorLayout,其中包含AppBarLayout和一个包含片段的FrameLayout

此片段中的一个片段包含顶部的TabLayout,一个列表槽RecyclerView以及底部的一个"自制的"工具栏。

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

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

enter image description here

我想修理底部"自制"工具栏保持可见但我无法实现。

这是片段布局

的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>

EDIT1: THIS问题似乎也是同样的问题。

8 个答案:

答案 0 :(得分:6)

试试这个布局:

getRealPath("/")

答案 1 :(得分:2)

试试这个

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

    <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
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/red"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:padding="15dp"
                app:cardBackgroundColor="@color/colorPrimary"
                app:cardCornerRadius="4dp"
                app:cardElevation="2dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="Nilesh Rathod"
                    android:textColor="#ffFFff" />
            </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:id="@+id/bottomnav"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_weight="1"
            android:background="@color/green"
            android:foregroundGravity="bottom"
            app:itemIconTint="@color/lightWhite"
            app:itemTextColor="@color/lightWhite"
            app:menu="@menu/menu"/>
    </RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

<强>结果

enter image description here

答案 2 :(得分:1)

当从属视图(SCROLLAppBarLayout)中的滚动内容小于视图高度时,此行为基本上会从RecyclerView中删除滚动标记NestedScrollView,即。当不需要滚动时。它还会覆盖偏移滚动视图,通常由AppBarLayout.ScrollingViewBehavior完成。添加页脚时效果很好,即。按钮,滚动视图或ViewPager,其中每页的内容长度可能不同。

https://gist.github.com/MaciejKaras/02bff315f00b87d80467a470424f22c3

已在https://stackoverflow.com/a/37293634

中回答

答案 3 :(得分:1)

要修复底栏,首先必须使用显示选项卡的活动。在该活动中使用不同的片段。在此activity_main_tab.xml

中添加tabLayout

activity_main_tab.xml

 <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:local="http://schemas.android.com/apk/res-auto"
        android:id="@+id/co_activity_root_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true">

            <android.support.design.widget.AppBarLayout
                local:theme="@style/Theme.AppBarOverlay"
                android:id="@+id/toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true">

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

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/toolbar_layout">

                <FrameLayout
                    android:id="@+id/fl_fragment_container"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                   />
            </RelativeLayout>
        </RelativeLayout>

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

对于片段视图,请使用

fragment_tab.xml

这里使用app:layout_scrollFlags =&#34;滚动| enterAlways&#34;在工具栏中使其可滚动

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

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"/>

            <android.support.design.widget.TabLayout
                android:id="@+id/tablayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabIndicatorColor="@color/white"
                app:tabIndicatorHeight="@dimen/profile_tablayout_indicator_height"
                android:background="?attr/colorPrimary"
                app:tabGravity="fill"/>

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

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

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

FragmentTabs.java

 public class FragmentTabs extends BaseFragment{

        private View rootView;
        private ViewPager viewPager;
        private TabLayout tabLayout;
        private Toolbar toolbar;
        private ViewPagerAdapter viewPagerAdapter;

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup viewGroupContainer, Bundle savedInstanceState) {
            rootViewSearch = inflater.inflate(R.layout.fragment_tab, viewGroupContainer, false);
            initializeLayout();
            setUpActionBar();
            setUpFragmentObjects();

            return rootView;
        }


        private void initializeLayout() {
            toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
            viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
            tabLayout = (TabLayout) rootView.findViewById(R.id.tablayout);
        }


        private void setUpActionBar() {
            getApplicationContext().setSupportActionBar(toolbarSearch);
            ActionBar actionBar = getApplicationContext().getSupportActionBar();
            if(actionBar != null){
                actionBar.setTitle(Constants.BLANK);
            }
        }


        private void setUpFragmentObjects() {
            viewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getChildFragmentManager());
            viewPager.setAdapter(searchViewPagerAdapter);
            tabLayout.setupWithViewPager(viewPager);
        }
    }

ViewPagerAdapter.java

public class ViewPagerAdapter extends FragmentPagerAdapter {

    public ViewPagerAdapter(Activity activity, FragmentManager fragmentManager) {
        super(fragmentManager);
    }


    @Override
    public Fragment getItem(int position) {
        Bundle bundle;
        switch (position) {
            case 0: // For Tab 1
               // use fragment for tab 1
                return fragment1;
            case 1: // For Tab 2
                // use fragment for tab 2
                return fragment2;
            case 2: // For Tab 3
                // use fragment for tab 3
                return fragment3;
            default:
                return null;
        }
    }

    @Override
    public int getCount() {
        return 3; // no. of Tabs
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0: // Title For Tab1
                return "Tab1";
            case 1: // Title For Tab2
                return "Tab2";
            case 2: // Title For Tab3
                return "Tab3";
            default:
                return null;
        }
    }
}

答案 4 :(得分:1)

你可以尝试在你的工具栏上添加像这样的dbMode。

您的appBarLayout似乎很好

我建议你看看这个链接: https://github.com/codepath/android_guides/wiki/Handling-Scrolls-with-CoordinatorLayout     `

 <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/holo_blue_light"
        android:fitsSystemWindows="true"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            app:layout_collapseMode="pin"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabIndicatorColor="@color/white"
          app:tabIndicatorHeight="@dimen/profile_tablayout_indicator_height"
            android:background="?attr/colorPrimary"
            app:tabGravity="fill"/>

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

答案 5 :(得分:1)

我面临同样的问题这是对我有用的方式

删除AppBarLayout layout_behavior,使其固定在最顶层。将FrameLayout layout_behavior定义为app:layout_behavior="@string/appbar_scrolling_view_behavior",以便在FrameLayout下方调整AppBarLayout。通过这种方式,框架布局的内容将滚动而不是工具栏。 CoordinatorLayout布局如下

<?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="com.next_tech.teebox.GridView">

    <android.support.design.widget.AppBarLayout
        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/colorPrimary"
            app:titleTextColor="@android:color/white" />

    </android.support.design.widget.AppBarLayout>
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">


</FrameLayout>


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

这是您的片段布局的XML,其recyclerView卷轴不会影响您的TabLayout和底部线性布局。

<?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/colorPrimary"
        app:tabMode="fixed"
        app:tabMaxWidth="0dp"
        android:elevation="4dp"
        app:tabIndicatorColor="@color/btnBackground"
        android:layout_height="?android:actionBarSize"
        />

    <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="?android:actionBarSize"
        android:orientation="horizontal"
        android:background="@color/colorPrimary"
        android:layout_gravity="bottom"
        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:layout_gravity="center"
            app:srcCompat="@android:drawable/ic_menu_delete" />
        <ImageView
            android:id="@+id/select"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_weight="1"
            app:srcCompat="@drawable/white_arrow" />

        <ImageView
            android:id="@+id/send"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="center"
            app:srcCompat="@drawable/ic_send_holo_dark" />

    </LinearLayout>

</LinearLayout>

我希望它可以帮助别人谢谢

了解更多信息 - Scrolling Behavior for Appbars in Android

答案 6 :(得分:1)

您无法在coordinatorlayout中执行此操作。所以使用RelativeLayout并在其设计中使用您自己的布局

答案 7 :(得分:0)

最好的解决方案将是建立这种层次结构

<ConstraintLayout>
    <CoordinatorLayout>
        <AppBarLayout>
           <ToolBar>
           <TabLayout>
        </AppBarLayout>
        <Inlude>
        Your layout which will be used to hide the toolbar upon interaction.
        </Include>
    </CoordinatorLayout>

 
   Other Widgets needs to be placed at a fixed position.

</ConstraintLayout>

别忘了添加

app:layout_behavior="@string/appbar_scrolling_view_behavior"

将以上行添加到包含的父视图组中。

让我们举一个我正在谈论的方法的例子

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@id/container"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:context=".activity.Dashboard">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:elevation="0dp"
            app:layout_constraintBottom_toTopOf="@+id/container"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/background"
                android:elevation="0dp"
                app:layout_scrollFlags="scroll|enterAlways|snap"
                app:popupTheme="@style/AppTheme.PopupOverlay"
                app:titleTextColor="#000000" />

            <com.google.android.material.tabs.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:tabBackground="@color/background"
                app:tabIndicatorColor="@color/colorAccent"
                app:tabMode="scrollable"
                app:tabSelectedTextColor="@color/black"
                app:tabTextColor="@color/black" />

        </com.google.android.material.appbar.AppBarLayout>

        <include
            android:id="@+id/include"
            layout="@layout/content_main" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <RelativeLayout
        android:id="@+id/btSend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="@dimen/_50sdp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@id/container"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/btReceive">

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fbSend"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/_30sdp"
            android:background="@color/colorAccent"
            android:src="@drawable/ic_upload"
            app:rippleColor="@color/colorAccent" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/fbSend"
            android:layout_alignRight="@id/fbSend"
            android:layout_alignBottom="@id/fbSend"
            android:layout_marginBottom="@dimen/_3sdp"
            android:elevation="@dimen/_10sdp"
            android:gravity="center"
            android:text="SEND"
            android:textColor="@color/white"
            android:textSize="@dimen/_8sdp" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/btReceive"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/_50sdp"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@id/container"
        app:layout_constraintEnd_toStartOf="@+id/btSend"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent">

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fbReceive"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/_30sdp"
            android:background="@color/colorAccent"
            android:src="@drawable/ic_download"
            app:rippleColor="@color/colorAccent" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/fbReceive"
            android:layout_alignRight="@id/fbReceive"
            android:layout_alignBottom="@id/fbReceive"
            android:layout_marginBottom="@dimen/_3sdp"
            android:elevation="@dimen/_10sdp"
            android:gravity="center"
            android:text="RECEIVE"
            android:textColor="@color/white"
            android:textSize="@dimen/_8sdp" />
    </RelativeLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/_7sdp"
        android:background="@drawable/bottom_bar_corner"
        android:padding="@dimen/_5sdp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <Button
            android:layout_width="@dimen/_24sdp"
            android:layout_height="@dimen/_24sdp"
            android:background="@drawable/ic_upload_download"
            android:minHeight="0dp"
            android:paddingTop="@dimen/_6sdp"
            android:paddingBottom="@dimen/_6sdp"
            android:textSize="@dimen/_13sdp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

到目前为止一切顺利。让我们看一下结果

enter image description here