首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在BottomBar后面浮动操作按钮

为什么在BottomBar后面浮动操作按钮
EN

Stack Overflow用户
提问于 2018-08-26 12:01:24
回答 2查看 921关注 0票数 1

我想要浮动行动按钮在中间的BottomBar和正面,而不是在背面,请指导我解决这个问题,我的图层代码如下…

代码语言:javascript
复制
<RelativeLayout 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">

<FrameLayout
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/floatingActionButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="31dp"
    android:clickable="true"
    android:elevation="0dp"
    app:backgroundTint="@color/colorPrimaryDark"
    app:borderWidth="0dp"
    app:elevation="8dp"
    app:fabSize="normal"
    app:layout_behavior="helpers."
    app:srcCompat="@drawable/ic_add_black_24dp"
    tools:ignore="VectorDrawableCompat" />

<com.roughike.bottombar.BottomBar
    android:id="@+id/bottomBar"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true"
    app:bb_tabXmlResource="@xml/bottombar_tabs" />

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-08-26 12:54:54

相对布局将视图排列在上面一个,因此视图按照您在xml中声明的顺序排列。

所以改变你的观点。

代码语言:javascript
复制
<RelativeLayout 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">

<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:clickable="true"
android:elevation="0dp"
app:backgroundTint="@color/colorPrimaryDark"
app:borderWidth="0dp"
app:elevation="8dp"
app:fabSize="normal"
app:layout_behavior="helpers."
app:srcCompat="@drawable/ic_add_black_24dp"
tools:ignore="VectorDrawableCompat" />

希望能帮上忙!

编辑的

代码语言:javascript
复制
 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:layout_alignParentBottom="true">
    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar_"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:bb_tabXmlResource="@xml/bottom_tabs" />
</LinearLayout>
票数 2
EN

Stack Overflow用户

发布于 2018-08-26 12:15:50

试着将FAB的位置更改为底部栏下的位置。

代码语言:javascript
复制
<RelativeLayout 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">

<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

 <com.roughike.bottombar.BottomBar
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
app:bb_tabXmlResource="@xml/bottombar_tabs" />



<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:clickable="true"
android:elevation="0dp"
app:backgroundTint="@color/colorPrimaryDark"
app:borderWidth="0dp"
app:elevation="8dp"
app:fabSize="normal"
app:layout_behavior="helpers."
app:srcCompat="@drawable/ic_add_black_24dp"
tools:ignore="VectorDrawableCompat" />

</RelativeLayout>

希望这能有所帮助。

还请确保fab的默认高程小于(6),而不是底部栏(8),因此您也需要处理这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52026043

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档