android - 微调器选择的文本在选择时不调整大小
问题描述
我有一个微调器,最大字符长度为 100。文本适合微调器,但是当我选择条目时,它不会在结果中自动调整大小。如果我删除 android:layout_height 则应用程序崩溃。
带有 autoSizeTextType 的微调器 xml
<Spinner
android:id="@+id/spinnerCompany"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="43dp"
android:paddingLeft="16dp"
android:spinnerMode="dropdown"
app:autoSizeTextType="uniform"
app:layout_constraintTop_toBottomOf="@+id/otpLabel"
tools:layout_editor_absoluteX="27dp" />
解决方案
为 Text 指定布局高度不是一个好习惯,而是使用 textSize 并让高度和宽度 wrap_content。
<Spinner
android:id="@+id/spinnerCompany"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp" (this is just random, find the ones fits your usage)
android:layout_marginTop="43dp"
android:paddingLeft="16dp"
android:spinnerMode="dropdown"
app:autoSizeTextType="uniform"
app:layout_constraintTop_toBottomOf="@+id/otpLabel"
tools:layout_editor_absoluteX="27dp" />
推荐阅读
- typescript - 如何使用可选的唯一字符串定义数组打字稿接口?
- ios - iOS PDFKit在PDFView中调整pdf框架
- ios - Swift 使用 GPUImage 发送压缩视频帧
- arrays - 将字符串解析为 ruby 中的哈希值
- flutter - Dart/Flutter - HttpServer 如何使用 websocket 更新图像?
- python - 将 List 中索引 [1:] 中的字符串转换为浮点数。当我收到值错误时:无法将字符串转换为浮点数
- java - 在我的 Apache 上,如何确保日志文件不会变得太大?
- python - VS Code 中的 Python 交互式窗口错误 - 无法写入文件 default.profraw:权限被拒绝
- data-modeling - 如何从 Excel 转移到设计数据仓库模型
- coordinates - 算法不合逻辑地停止?