在我的activity_navigation.xml
我把我的FAB
放在这里。下面 的是:如何在所有活动中显示FAB
<android.support.v4.widget.DrawerLayout
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"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content_frame">
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:menu_icon="@drawable/quick_apply"
android:layout_gravity="bottom|right"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp">
<com.github.clans.fab.FloatingActionButton
android:id="@+id/view_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/imgicon"
fab:fab_size="mini"
fab:fab_label="View Images" />
<com.github.clans.fab.FloatingActionButton
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/camicon"
fab:fab_size="mini"
fab:fab_label="Camera" />
</com.github.clans.fab.FloatingActionMenu>
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_navigation_drawer"
android:background="@color/tableHeader"/>
我在我的NavigationActivity
设置此xml
哪里,这将是像我BaseActivity
,然后将其推广到我的所有其他Activities
。
我的问题,当运行应用程序FAB
不显示,因为它已被我分配给content_frame
xml覆盖。但如果我把com.github.clans.fab.FloatingActionMenu
放在我的其他activities's xml
之一,例如在我的Home Screen
中,它会显示它,但我不知道如何显示FAB
而不重复添加我的xml
。 FAB
的所有行动我把它放在我的NavigationActivity
上。
谢谢你的帮助。
更新 通过我使用FrameLayout
命名content_frame
我的其他activities
以显示Activity
喜欢的xml
在我Home Screen
这样
FrameLayout contentFrameLayout = (FrameLayout) findViewById(R.id.content_frame);
getLayoutInflater().inflate(R.layout.activity_home, contentFrameLayout);
您的NavigationView具有匹配父级的高度。你框架布局也高度匹配父母,他们将重叠,你尝试设置你的框架布局与20dp高度,并看到 – kggoh
@kggoh它仍然不显示:(我试图把20dp layout_height在framelayout。 – natsumiyu
@kggoh我试过把20dp高度放在我现在显示的晶圆厂的其他活动xml中有没有办法解决这个问题?因为我需要在屏幕上显示整个活动的内容 – natsumiyu