使FAB不会被夹在底部导航栏中 [英] Make FAB not to be clipped inside bottom navigation bar

查看:78
本文介绍了使FAB不会被夹在底部导航栏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将底部导航栏与FAB重叠.我希望我的导航栏看起来像这样:

i'm trying to overlap the bottom navigation bar with a FAB. I want my navigationbar to look like this:

但是相反,它像这样切断了按钮:

But instead it cuts off the button like so:

如何防止FAB被切断?这是我的XML:

How do I prevent the FAB from being cut off? Here's my XML:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mobgen.designsprintapp.ui.main.MainActivity">

    <LinearLayout 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:orientation="vertical">

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

        <android.support.design.widget.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:background="?android:attr/windowBackground"
            android:backgroundTint="@color/colorPrimary"
            app:itemBackground="@color/colorPrimary"
            app:itemIconTint="@color/nav_item_color_state"
            app:itemTextColor="@android:color/black"
            app:menu="@menu/navigation" >

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/tools"
                android:layout_width="56dp"
                android:layout_height="56dp"
                android:layout_gravity="center"
                android:layout_marginBottom="8dp"
                android:elevation="6dp"
                android:scaleType="center"
                app:srcCompat="@drawable/play" />
            </android.support.design.widget.BottomNavigationView>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

推荐答案

您的问题是您已明确指定FloatingActionButton的width和heigh参数,而不能采用任何宽度/高度. app:fabSize 参数为晶圆厂指定3种尺寸:自动,迷你和标准.

Your problem is that you have explicitly specified width and heigh parameters of FloatingActionButton, whereas it cannot take any width/height. app:fabSize parameters specifies 3 sizes for the fab: auto, mini, and normal.

layout_widthlayout_height保留为wrap_content,并使用app:fabSize="normal"(或列表中的其他参数)指定所需的晶圆厂大小.

Leave layout_width and layout_height as wrap_content, and specify the desired fab size using app:fabSize="normal" (or other parameter from the list).

另外,将BottomNavigationView的高度设置为wrap_content,因为晶圆厂具有一些内部填充物.

Additionally, make BottomNavigationView's height wrap_content, because fab has some internal paddings.

要在封闭布局之外绘制子代,请应用 android:clipChildren="false" 到封闭的ViewGroup.

In order to draw a child outside of the enclosing layout apply android:clipChildren="false" to the enclosing ViewGroup.

这篇关于使FAB不会被夹在底部导航栏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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