Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TextInputLayout/EditText is not full size and cuts off text

I have a fragment which contains a calculator (Just three TextInputEditTexts which listen for input).

These inputs are set out in a RelativeLayout as shown below-

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingTop="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingBottom="16dp">

    <android.support.design.widget.TextInputLayout
        android:id="@+id/binomial_probability_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/label_probability"
        android:paddingBottom="16dp">
        <android.support.design.widget.TextInputEditText
            android:id="@+id/binomial_probability_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:inputType="numberDecimal"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/binomial_trials_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/label_trials"
        android:paddingBottom="16dp"
        android:layout_below="@+id/binomial_probability_wrapper">
        <android.support.design.widget.TextInputEditText
            android:id="@+id/binomial_trials_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:inputType="numberSigned"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:id="@+id/binomial_successes_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/label_successes"
        android:paddingBottom="16dp"
        android:layout_below="@+id/binomial_trials_wrapper">
        <android.support.design.widget.TextInputEditText
            android:id="@+id/binomial_successes_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:inputType="numberSigned"/>
    </android.support.design.widget.TextInputLayout>

</RelativeLayout>

I have also tried using a LinearLayout with each input on a separate row, but that had the same result.

As you can see in this image- enter image description here

the bottom input is cut off. If I measure it on my screen it is clearly a different size, but Android returns the same value for the heights of each layout and input.

Any suggestions as to how to fix this are welcome.

Edit: Some extra information. The layout bounds show that the text cursor is actually taller than the height of the bottom TextInputEditText. The top have the correct height.

Second edit: I added the a TextView below (For output) and that is now cut off, while the TextInputEditText is now the same as the others.

like image 966
Theo Pearson-Bray Avatar asked Jul 18 '16 15:07

Theo Pearson-Bray


1 Answers

As saying in official github page:

TextInputLayout provides two height variations for filled and outline text fields, standard and dense. Both box styles default to the standard height.

In order to reduce the height of a text box, you can use a dense style, which will reduce the vertical padding within the text box. You can achieve this by applying the appropriate styles to your TextInputLayout and TextInputEditText, depending on whether you are using a filled or outline text field

So try to apply @style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense to your TextInputLayout or change padding for TextInputEditText

like image 93
Danylo.Vus Avatar answered Sep 19 '22 01:09

Danylo.Vus