ConstraintLayout won't let me set a constraint connecting the view to the edge of the screen

Here is the image for which it now looks. I want the float button to be right at the bottom of the screen. Here I am trying to do this. So here is the activity_main file:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    android:fitsSystemWindows="true"
    tools:context="com.example.jaden.finances.MainActivity">


    <android.support.v7.widget.Toolbar
        android:id="@+id/appBarLayout"
        android:layout_width="360dp"
        android:layout_height="81dp"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        tools:layout_editor_absoluteY="0dp"
        tools:layout_editor_absoluteX="0dp" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="40dp"
        android:layout_height="40dp"
        app:srcCompat="@android:drawable/ic_dialog_email"
        tools:layout_editor_absoluteY="0dp"
        tools:layout_editor_absoluteX="0dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:text="Name"
        android:ems="10"
        android:id="@+id/editText"
        android:hint="@string/edit_message"
        tools:layout_editor_absoluteY="83dp"
        tools:layout_editor_absoluteX="16dp" />

    <Button
        android:text="@string/button_send"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button3"
        android:onClick="sendMessage"
        tools:layout_editor_absoluteX="249dp"
        tools:layout_editor_absoluteY="81dp" />

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:layout_editor_absoluteY="126dp"
        tools:layout_editor_absoluteX="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/options">

        </LinearLayout>
    </ScrollView>
</android.support.constraint.ConstraintLayout>

I'm not sure what I'm doing wrong. When I go to the graphic design editor and click and drag the edges to create a new constraint, it will not click on the edges of the screen. A Google search does not produce anything.

+4
source share
1 answer

. , .

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
     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"
     android:fitsSystemWindows="true"
     tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
    android:id="@+id/appBarLayout"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_marginBottom="20dp"
    android:layout_marginRight="20dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:srcCompat="@android:drawable/ic_dialog_email" />

<EditText
    android:id="@+id/editText"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="8dp"
    android:ems="10"
    android:hint="Name"
    android:inputType="text"
    android:text="Name"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/appBarLayout" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="sendMessage"
    android:text="Send"
    app:layout_constraintLeft_toRightOf="@+id/editText"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/editText" />

<ScrollView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/editText">

    <LinearLayout
        android:id="@+id/options"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    </LinearLayout>
</ScrollView>

+2

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


All Articles