Rendering Problems using FloatingActionButton between two layouts stop working after updating to dependencies 24.2.0

北战南征 提交于 2019-12-01 10:13:15

问题


As I mentioned in the question, my FloatingActionButton between two layouts, check classic example here, stopped working after updating gradle dependencies to 24.2.0.

I have checked similar questions and answers. After digging, I found an answer explaining the reason, see here. The solutions is extremely useful for cases where you want to place the FAB at the bottom of the layout. However, this is not working between two layouts.

Sorry for creating another question/issue, and not continuing the discussion in the solution I found, but apparently, I don't have enough reputation to create a comment.

Thanks in advance for your time.

<?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>

回答1:


layout_anchor only works with direct children of CoordinatorLayout. You'll need to change your layout_anchor to use a different view, such as your project_detailed_holder.



来源:https://stackoverflow.com/questions/39022189/rendering-problems-using-floatingactionbutton-between-two-layouts-stop-working-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!