So I have a simpleEditText
within a ConstraintLayout
. What I want is for the user to start typing and the EditText
to expand to fit their input, which works as expected until I add a hint. Then the view seems to be constrained to the width of the hint, with no change at all with input.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/add_menu_item_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/add_menu_item_title" />
<EditText
android:inputType="textCapWords"
android:id="@+id/add_menu_item_name"
style="@style/BlockListItem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin"
android:layout_marginTop="@dimen/margin"
android:layout_marginEnd="@dimen/margin"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/add_menu_item_toolbar" />
<View
android:id="@+id/add_menu_item_stock_frame"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/margin"
android:layout_marginTop="@dimen/margin"
android:layout_marginEnd="@dimen/margin"
android:background="@drawable/frame_border"
app:layout_constraintBottom_toBottomOf="@id/add_menu_item_frame_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/add_menu_item_name" />
<LinearLayout
android:id="@+id/add_menu_item_stock_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="@id/add_menu_item_stock_frame"
app:layout_constraintStart_toStartOf="@id/add_menu_item_stock_frame"
app:layout_constraintTop_toTopOf="@id/add_menu_item_stock_frame" />
<com.google.android.material.button.MaterialButton
android:id="@+id/add_menu_item_add_stock"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:layout_marginEnd="@dimen/margin"
android:text="@string/add_menu_item_add_stock"
app:icon="@drawable/baseline_add_24"
app:layout_constraintBottom_toBottomOf="@id/add_menu_item_stock_frame"
app:layout_constraintEnd_toEndOf="@id/add_menu_item_stock_frame"
app:layout_constraintTop_toBottomOf="@id/add_menu_item_stock_container" />
<Space
android:id="@+id/add_menu_item_frame_margin"
android:layout_width="match_parent"
android:layout_height="@dimen/margin"
app:layout_constraintTop_toBottomOf="@id/add_menu_item_add_stock" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/add_menu_item_price_container"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin"
android:layout_marginTop="@dimen/margin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/add_menu_item_stock_frame"
app:layout_goneMarginTop="@dimen/margin">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_menu_item_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="6"
android:hint="@string/menu_add_price_hint"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/add_menu_item_suggested_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin"
app:layout_constraintBottom_toBottomOf="@id/add_menu_item_price_container"
app:layout_constraintStart_toEndOf="@id/add_menu_item_price_container"
app:layout_constraintTop_toTopOf="@id/add_menu_item_price_container" />
<com.google.android.material.button.MaterialButton
android:id="@+id/add_menu_item_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin"
android:text="@string/menu_add_add"
app:layout_constraintBottom_toBottomOf="@id/add_menu_item_price_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/add_menu_item_price_container" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>