如何在底部栏/导航底部视图的顶部具有浮动操作按钮,就像它在图片中显示的那样!请帮帮我!

发布于 2017-05-09 03:58:39
您需要使用FloatingActionButton的elevation属性。
elevation="8dp“适用于我。
示例布局:
<FrameLayout 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_weight="1">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="@string/title_home" />
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?android:attr/windowBackground"
app:menu="@menu/navigation" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="40dp"
android:clickable="true"
app:elevation="8dp"
app:srcCompat="@android:drawable/ic_input_add" />
</FrameLayout>发布于 2017-05-09 00:00:54
底部的栏是他们在应用程序中创建的东西。它不是android本身的功能按钮(Home/Back/App)。
因此,像任何视图一样,将视图放在另一个视图之上是非常容易的。
这可以通过Relative layout来完成
另一件需要注意的事情是通过android studio,其中一个android活动模板实际上创建了一个悬停按钮的示例,类似于您的图片中所示。使用向导创建活动,然后根据需要移动按钮。

发布于 2017-05-09 05:21:18
您可以在xml中使用FloatingActionButton属性。
设置FloatingActionButton layout_anchor (要附加的视图的id )和layout_anchorGravity。
https://stackoverflow.com/questions/43852100
复制相似问题