相关疑难解决方法(0)

隐藏在底部导航栏后面的Android浮动操作按钮

android编程的新手,现在正在挣扎。我正在使用android studio的默认“导航抽屉活动”。最重要的是,我从添加了一个底部栏https://github.com/roughike/BottomBar。但是,在补充说我的FAB隐藏在底部栏后面之后。

这是Scrrenshot-

在此处输入图片说明

我知道这是某种风格问题。我试图为FAB提供bottomMargin。但是,它不起作用。

这是我的代码-

app_bar_main.xml

<?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.bhramaan.android.bhramaan.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/BhramaanTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/BhramaanTheme.PopupOverlay" />

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

    <include layout="@layout/content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

    <com.roughike.bottombar.BottomBar
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_gravity="bottom|end"
        android:layout_height="60dp"
        android:layout_alignParentBottom="true"
        app:bb_behavior="shy"
        android:background="@color/bottomBar"
        app:bb_activeTabColor="@color/white"
        app:bb_tabXmlResource="@xml/bottombar_tabs" />

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

需要一些指导来解决此问题。

android android-layout

7
推荐指数
1
解决办法
8446
查看次数

带有片段和底部导航栏的 Android FloatingActionButton

我正在创建一个具有以下结构的 android 应用程序:

  • 主要活动有一个底部导航栏在 3 个不同的片段之间切换
  • 其中 2 个片段将显示项目列表,并使用浮动操作按钮 (FAB) 来添加新项目
  • 第三个片段将展示一些不同的东西,不需要 FAB。

基于此,似乎 FAB 应该“属于”列表片段,而不是主要活动。

我目前遇到的问题是 FAB 将自己隐藏在底部导航栏后面,如本问题所示。那里有一个很好的解决方案,但这取决于 FAB 与底部导航栏的布局相同。

有没有办法让 FAB 不将自己隐藏在底部导航后面,而无需将 FAB 移动到主要活动(这打破了片段的模块化)?


我的活动布局如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_insetEdge="bottom"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

其中“片段容器”被选定的片段替换,如下所示:

    TodoListFragment fragment = new TodoListFragment();

    //if we were started with an intent, pass on any special arguments
    fragment.setArguments(getIntent().getExtras()); …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

7
推荐指数
1
解决办法
2361
查看次数