Andrew
Andrew

Reputation: 4732

prefixtext changes textInputlayout hight and makes it huge

I am using a textinputlayout in combination with a textinputedittext as a layout for my viewstub. Everything works fine, until I try to add a prefixtext. With this, the layout gets messed up and the textInputLayout is huge. I will provide my code and some screenshots

Viewstub Layout

<?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">

    <data>
        <import type="kotlin.jvm.functions.Function1" />

        <import type="kotlin.Unit" />

        <variable
            name="vBility"
            type="Boolean" />
        <variable
            name="vForm"
            type="String" />
        <variable
            name="hint"
            type="String" />
        <variable
            name="iType"
            type="Integer" />
        <variable
            name="mText"
            type="String" />
        <variable
            name="mPrefixText"
            type="String" />
        <variable
            name="mTextListener"
            type="Function1&lt;String,Unit>" />
    </data>


    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="@{vBility}">

        <com.example.app.presentation.util.view.FixedInputTextLayout
            android:id="@+id/app_default_et"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:layout_width="@dimen/wrapContent"
            android:layout_height="wrap_content"
            android:hint="@{hint}"
            android:visibility="@{vBility}"
            app:prefixText="TEST" <!-- Making problems -->
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:validate_form="@{vForm}">

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="@{iType}"
                android:text="@{mText}"
                app:onTextChanged="@{mTextListener}"
                android:textSize="@dimen/font_text_large" />

        </com.example.app.presentation.util.view.FixedInputTextLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Viewstub

<ViewStub
        android:id="@+id/app_standard_btNumber_et"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:inflatedId="@+id/app_standard_btNumber_et"
        android:layout="@layout/app_standard_textinputlayout"
        android:visibility="@{showBtNumber}"
        app:hint="@{btValidator.btNumberHint}"
        app:iType="@{0x00000002}"
        app:layout_constraintEnd_toStartOf="@+id/margin_right"
        app:layout_constraintStart_toEndOf="@+id/app_standard_phoneNumber_et"
        app:layout_constraintTop_toBottomOf="@+id/app_standard_eMail_et"
        app:mText="@{btValidator.btNumber}"
        app:mTextListener="@{btValidator.onBtNumberChanged}"
        app:vBility="@{showNumber}"
        app:vForm="@{btValidator.btNumberEM}" />

Layout without prefixText

enter image description here

enter image description here

Layout with prefixText

enter image description here

enter image description here

enter image description here

Upvotes: 1

Views: 122

Answers (1)

Alireza Abbasian
Alireza Abbasian

Reputation: 179

set this line to inputEditText

android:maxHeight="@dimen/_100sdp"

or set singleLine = true

Upvotes: 0

Related Questions