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-
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.
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
andTextInputEditText
, 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With