正如我在问题中提到的,我的 FloatingActionButton 位于两个布局之间,请检查经典示例here https://stackoverflow.com/questions/24459352/how-can-i-add-the-new-floating-action-button-between-two-widgets-layouts,将 gradle 依赖项更新到 24.2.0 后停止工作。
我查过类似的问题和答案。经过挖掘,我找到了解释原因的答案,请参阅here https://stackoverflow.com/a/35843941/5694271。对于要将 FAB 放置在布局底部的情况,该解决方案非常有用。但是,这在两个布局之间不起作用。
很抱歉创建另一个问题/问题,并且没有继续我找到的解决方案中的讨论,但显然,我没有足够的声誉来创建评论。
在此先感谢您的时间。
<?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"
tools:context=".Screens.DetailActivity">
<LinearLayout
android:id="@+id/project_detailed_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:transitionName="tMainHolder">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/article_list_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/article_collection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:requiresFadingEdge="vertical" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabEdit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_mode_edit_black_24dp"
android:tint="@android:color/white"
app:layout_anchor="@id/header"
app:backgroundTint="@color/colorPrimary"
app:elevation="4dp"
app:layout_anchorGravity="bottom|right|end"
android:alpha="0.0"/>
</android.support.design.widget.CoordinatorLayout>
layout_anchor
只适用于CoordinatorLayout
。你需要改变你的layout_anchor
使用不同的视图,例如您的project_detailed_holder
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)