【发布时间】:2018-08-24 19:05:32
【问题描述】:
我正在制作一个应用程序,其中我的浮动操作按钮与我的底部导航栏重叠 我在 SO 上进行了搜索,但没有得到任何适当的解决方案,请提供任何帮助
我已经为底部导航布局制作了一个单独的 xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:menu="@menu/navigation"
android:backgroundTint="@color/nav_color"
app:itemIconTint="@color/bottom_nav_fore_color"/>
</android.support.constraint.ConstraintLayout>
这里是activity main的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="@color/colorPrimary">
<com.ct.listrr.widget.BounceScrollView
android:layout_height="match_parent"
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android" >
<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"
tools:context="com.ct.listrr.MainActivity"
>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="330dp"
android:layout_height="340dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="25dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
<LinearLayout
android:id="@+id/club_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.ct.listrr.widget.CustomTextViewMedium
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:textSize="40sp"
android:text="Clubs"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:textColor="@color/White"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/clubrecycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:id="@+id/lounge_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.ct.listrr.widget.CustomTextViewMedium
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:textSize="40sp"
android:text="Lounge"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:textColor="@color/White"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/loungerecycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:id="@+id/cafe_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.ct.listrr.widget.CustomTextViewMedium
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:textSize="40sp"
android:text="Cafe"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:textColor="@color/White"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/caferecycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
<LinearLayout
android:id="@+id/rooftop_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.ct.listrr.widget.CustomTextViewMedium
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:textSize="40sp"
android:text="RoofTop"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:textColor="@color/White"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/rooftoprecycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
</com.ct.listrr.widget.BounceScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_my_icon"
android:layout_margin="16dp"
app:rippleColor="@color/colorAccent"/>
<include layout="@layout/bottom_nav_bar"
android:id="@+id/bottom_nav_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
【问题讨论】:
-
您的问题不清楚..请明确提及您需要归档什么..根据 android 设计指南,FAB 应该高于您正在创建的所有其他视图
-
是的 fab 应该在每个视图之上,但我的 fab 没有显示在我的底部导航栏上方