Android 浮动操作按钮未显示-viewpager
我在这里读了一些关于这个问题的帖子,但是我无法显示晶圆厂。我尝试了不同的方法,但我不知道到底发生了什么Android 浮动操作按钮未显示-viewpager,android,android-viewpager,android-coordinatorlayout,floating-action-button,Android,Android Viewpager,Android Coordinatorlayout,Floating Action Button,我在这里读了一些关于这个问题的帖子,但是我无法显示晶圆厂。我尝试了不同的方法,但我不知道到底发生了什么 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="112dp"
android:background="@color/colorPrimary"
android:elevation="@dimen/elevation_toolbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_marginLeft="@dimen/list_toolbar_side_margin"
android:layout_marginRight="@dimen/list_toolbar_side_margin"
app:layout_collapseMode="pin" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
style="@style/AppTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextAppearance="@style/AppTabTextAppearance"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_id"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_add"
/>
我也尝试过使用一个应用程序:layout\u-anchor=“@id/viewpager”或应用程序:layout\u-anchor=“@id/app\u-bar\u-layout”和**应用程序:layout\u-anchorGravity=“bottom | right”**一起使用,但没有起作用。该晶圆厂由viewpager覆盖。我怎样才能避免呢
我附上主要活动的图片。您将看到一个按钮“添加植物”。该按钮应更换为晶圆厂
在您的xml中尝试此方法
app:layout_anchor="@id/viewpager"
app:layout_anchorGravity="bottom|right"
移除
android:layout_gravity="end|bottom"
尝试将FloatingAction按钮插入frameLayout,并将此布局插入主布局。。它对我有用
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
.
.
.
<FrameLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add_room"
android:layout_width="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginRight="8dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:src="@drawable/ic_add"
app:fabSize="normal" />
</FrameLayout>
.
.
.
</android.support.constraint.ConstraintLayout>
.
.
.
.
.
.
要将晶圆厂放在右下角吗?是的。我需要晶圆厂住在寻呼机上。激活了哪个viewpager片段并不重要。你修复了吗?我使用了相同的prbI应用程序:layout_ancorgravity=“bottom | right”,但它不起作用。我忘了在我的问题中加上这个。我将更新id。