Якорь не может быть изменен после начала измерения CoordinatorLayout до завершения макета? - PullRequest
0 голосов
/ 21 февраля 2019

Здравствуйте, друзья, пожалуйста, помогите мне, в чем проблема, здесь все нормально работает на SDK 23, теперь я обновляю SDK с 23 до 28, что дает эту ошибку.В основном это ошибка в теге привязки. Я не знаю, как исправить эту ошибку, пожалуйста, есть какой-нибудь эксперт, который может мне помочь

Якорь не может быть изменен после того, как измерение CoordinatorLayout начинается до завершения макета?вот мой код

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:orientation="vertical"
              android:gravity="center"
              android:layout_height="match_parent">

    <!--<include layout="@layout/base_toolbar"/>-->
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/myCoordinatorLayout"
        android:layout_width="match_parent"
        android:gravity="center"
        android:layout_height="match_parent"
        >

        <LinearLayout
            android:id="@+id/toDoEmptyView"
            android:orientation="vertical"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:src="@drawable/empty_view_bg"
                android:layout_width="100dp"
                android:layout_height="100dp"/>

            <TextView
                android:text="@string/no_to_dos"
                android:textColor="@color/secondary_text"
                android:textSize="16sp"
                android:paddingTop="4dp"
                android:paddingBottom="8dp"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>


        <!--<include layout="@layout/base_toolbar"/>-->


        <!--</android.support.design.widget.AppBarLayout>-->


        <com.rock.notepad.minimaltodo.Utility.RecyclerViewEmptySupport
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/toDoRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


        <android.support.design.widget.FloatingActionButton
            android:src="@drawable/ic_add_white_24dp"
            android:id="@+id/addToDoItemFAB"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            app:layout_anchor="@id/myCoordinatorLayout"
            app:layout_anchorGravity="bottom|right|end"

            />


    </android.support.design.widget.CoordinatorLayout>
</LinearLayout>

1 Ответ

0 голосов
/ 21 февраля 2019

В теге FloatingActionButton не используйте layout_anchor для CoordinatorLayout.Используйте нижестоящий дочерний элемент CoordinatorLayout.

Пожалуйста, проверьте это. Это работает для меня

<android.support.design.widget.FloatingActionButton
            android:src="@drawable/ic_add_white_24dp"
            android:id="@+id/addToDoItemFAB"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            app:layout_anchor="@id/toDoEmptyView"
            app:layout_anchorGravity="bottom|right|end"

            />
...