Issue
I have some very short text input (like only 2 numeric characters) yet using the endIcon will hog half of my textview and will cut off and display ellipses. I cannot make the TextInputLayout wider so I how can I display the full 2 characters (or more) while using endIconDrawable?
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="80dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_height="40dp"
android:background="@drawable/text_input_assessment"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:endIconDrawable="@drawable/ptx_down_arrow_android"
app:endIconTint="@color/colorPtxDarkBlue">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/dropdownDay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:fontFamily="@font/truenorg"
android:textSize="15sp"
app:autoSizeTextType="uniform"
app:autoSizeMinTextSize="10sp"
app:autoSizeMaxTextSize="15sp"
app:autoSizeStepGranularity="1sp"
android:inputType="none"
android:maxLines="1"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:singleLine="true"
android:text="12"
android:textAlignment="viewStart"
android:textColor="@color/colorPtxDarkBlue"
tools:ignore="LabelFor" />
</com.google.android.material.textfield.TextInputLayout>
Solution
It is a workaround, not a final solution.
You can reduce the padding between the text and endIcon
by adding a negative value in android:drawablePadding
.
Something like:
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/dropdownDay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:drawablePadding="-12dp"
../>
A final note. You don't need to use android:background="@drawable/text_input_assessment"
to have rounded corners. Just add app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Rounded"
in the TextInputLayout
with:
<style name="ShapeAppearanceOverlay.Rounded" parent="">
<item name="cornerSize">50%</item>
</style
Answered By - Gabriele Mariotti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.