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>
3
Answers
It is a workaround, not a final solution.
You can reduce the padding between the text and
endIcon
by adding a negative value inandroid:drawablePadding
.Something like:
A final note. You don’t need to use
android:background="@drawable/text_input_assessment"
to have rounded corners. Just addapp:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Rounded"
in theTextInputLayout
with:You’ve defined a style for it already
So, the above line will add the dropdown icon automatically. I think you’ll need to remove this line
Maybe the above line is overlapping the default icon
Then if you want to set tint to the drawable, just create a custom style
And you add this two lines if you like
Also i suggest that you remove this line and add it to the com.google.android.material.textfield.TextInputLayout instead.
Okay, i created this just now after 2hours and it worked very fine for me..
styles.xml
Don’t worry about the constans e.g @color/colorPrimary. What matters is the parent theme.
Then add this to styles.xml also
You can now modify your activity_main.xml
to