Constraint Layout gives error in default template in Android Studio 2.3

I updated Android Studio 2.3, after which I get the default ConstrainLayoutas an xml template.

But I have RelativeLayouta mock child, and I get the following warning.

This view is not limited, it only has development-time positions, so it will jump to (0,0) unless you add restrictions.

The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with development-time attributes (for example, as layout_editor_absoluteX.) These attributes are not used in runtime, so if you click on the layout on the device, widgets can be displayed elsewhere. than shown in the editor. To fix this, make sure that the widget has both horizontal and vertical drag and drop constraints from the border connections.

<?xml version="1.0" encoding="utf-8"?>
<layout 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.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:context="com.pratikbutani.demoapp.MainActivity"
        tools:showIn="@layout/activity_main">

        <RelativeLayout 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:id="@+id/content_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:showIn="@layout/activity_main"
            tools:layout_editor_absoluteY="8dp"
            tools:layout_editor_absoluteX="8dp">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/my_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true" />

        </RelativeLayout>

    </android.support.constraint.ConstraintLayout>
</layout>

Getting a warning about RelativeLayoutwhat should I do?

+6
source share
7 answers

"", " " → " " enter image here

+9

...

enter image description here

+3

, . , , , android. , , , . , , , .

https://i.stack.imgur.com/r8L8O.png

+1

- , ,

tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"

( - 8dp margin top 8dp) ( Preview of Android Studio),

, tools:layout_editor_absoluteY="8dp", tools:layout_editor_absoluteX="8dp"

0

, , Android. , android: layout_marginTop = "12dp", app: layout_constraintTop_toTopOf = "", .

0

, . "/", . ;

0

, ConstraintLayout, RelativeLayout ... , , , . RelativeLayout ConstraintLayout.

, , , :

tools:layout_editor_absoluteX tools:layout_editor_absoluteY RelativeLayout, RelativeLayout . - absoluteX absoluteY . , RelativeLayout ConstraintLayout , RelativeLayout:

    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"

, RelativeLayout ( ), ( ).

, . !

0

Source: https://habr.com/ru/post/1673608/


All Articles