How do I get ConstraintLayout to reach the app bar when I start the application

42 views Asked by At

I have a ConstraintLayout like this:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.dictionary.DictionaryFragment">


<EditText
    android:id="@+id/editTextSearch"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:autofillHints=""
    android:background="@color/colorPrimaryDark"
    android:hint="Enter word"
    android:textAppearance="@style/TextAppearance.AppCompat.Medium"
    android:textColor="#FFFFFF"
    app:layout_constraintBottom_toTopOf="@+id/btnSubmit"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/btnSubmit"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="4dp"
    android:text="Search"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/editTextSearch" />

    </androidx.constraintlayout.widget.ConstraintLayout>

Which looks like this in the preview: enter image description here

However when I run the app the searchbar doesn't seem to reach the top of the app bar. How can I fix this? enter image description here

This is the way it looks with a red layout: enter image description here

0

There are 0 answers