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>
CodePudding user response:
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
CodePudding user response:
You've defined a style for it already
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
So, the above line will add the dropdown icon automatically. I think you'll need to remove this line
app:endIconDrawable="@drawable/ptx_down_arrow_android"
Maybe the above line is overlapping the default icon
Then if you want to set tint to the drawable, just create a custom style
<style name="CustomAutoCompleteLayout" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu">
<item name="endIconTint">@color/colorPtxDarkBlue</item>
</style>
And you add this two lines if you like
style="@style/CustomAutoCompleteLayout"
android:theme="@style/CustomAutoCompleteLayout"
Also i suggest that you remove this line and add it to the com.google.android.material.textfield.TextInputLayout instead.
android:paddingTop="10dp"
android:paddingBottom="10dp