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? enter image description here

          <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>

推荐答案

这是一种变通办法,而不是最终解决方案.

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"
        ../>

enter image description here

最后一个音符.圆角不需要使用android:background="@drawable/text_input_assessment".只需在TextInputLayout中添加app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Rounded",并添加:

  <style name="ShapeAppearanceOverlay.Rounded" parent="">
    <item name="cornerSize">50%</item>
  </style

Java相关问答推荐

Java JAR环境(JRE)是否支持模块?

Oracle DUAL表上使用DDL时jOOQ问题的解析'

关于泛型的覆盖规则

如何确定springboot在将json字段转换为Dto时如何处理它?

在AVL树的Remove方法中使用NoSuchElementException时遇到问题

测试期间未执行开放重写方法

与不同顺序的组进行匹配,不重复组但分开

声明带有泛型的函数以用作查找映射中的值

为什么我的回收视图会显示重复的列表?

如果按钮符合某些期望,如何修改它的文本?

我可以在@Cacheable中使用枚举吗

组合连接以从两个表返回数据

将java.util.Date(01.01.0001)转换为java.time.LocalDate将返回29.12.0000

未调用OnBackPressedCallback-Activitiy立即终止

活泼的一次判断成语,结果中等

在Java中使用StorageReference将数据从Firebase存储添加到数组列表

无法在Java中获取ElastiCache的AWS CloudWatch指标

使用Java线程进行并行编程

spring 数据Elastic search 与 spring 启动数据Elastic search 之间的区别是什么?

为什么我得到默认方法的值而不是被覆盖的方法的值?