作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些非常短的文本输入(比如只有 2 个数字字符),但使用 endIcon 会占用我的 TextView 的一半,并且会切断并显示省略号。我无法使 TextInputLayout 更宽,所以我如何在使用 endIconDrawable 时显示完整的 2 个字符(或更多)?
<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>
最佳答案
这是一种解决方法,而不是最终解决方案。
您可以减少文本和 endIcon
之间的填充。通过在 android:drawablePadding
中添加负值.
就像是:
<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"
../>
android:background="@drawable/text_input_assessment"
有圆角。只需添加
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Rounded"
在
TextInputLayout
和:
<style name="ShapeAppearanceOverlay.Rounded" parent="">
<item name="cornerSize">50%</item>
</style
关于java - Android Material TextInputLayout endIcon 截断 MaterialAutoCompleteTextView 中的文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72192793/
我想开始在我的 Android 应用程序中使用 Material 组件,但我在使用 MaterialAutoCompleteTextView 时遇到了一些麻烦。我希望它的行为类似于标准的 AutoCo
我有一些非常短的文本输入(比如只有 2 个数字字符),但使用 endIcon 会占用我的 TextView 的一半,并且会切断并显示省略号。我无法使 TextInputLayout 更宽,所以我如何在
我是一名优秀的程序员,十分优秀!