android - -TextView 太长时布局中断
问题描述
我正在使用RecyclerView
withConstrainLayout
列出所有这样的文件
但不知何故,当文本很长时,第一行和第二行之间的空间增加了(上图)。我不知道到底是什么问题。这是我的代码:
项目.xml:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layoutItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground">
<ImageView
android:id="@+id/imgFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_folder" />
<TextView
android:id="@+id/txtFileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp
app:layout_constraintBottom_toTopOf="@+id/txtLastModified"
app:layout_constraintStart_toEndOf="@+id/imgFile"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/txtLastModified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgFile"
app:layout_constraintTop_toBottomOf="@+id/txtFileName" />
<TextView
android:id="@+id/txtAdditionalInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
app:layout_constraintBottom_toBottomOf="@+id/txtLastModified"
app:layout_constraintStart_toEndOf="@+id/txtLastModified"
app:layout_constraintTop_toTopOf="@+id/txtLastModified" />
</android.support.constraint.ConstraintLayout>
奖金:
解决方案
添加android:maxLines="1"
“ textview
txtFileName”
推荐阅读
- flutter - How to only change the time in DateTime?
- mysql - 在 phpmyadmin 中设置 int 类型长度无限制
- python - 使用多索引注释散点图
- github - GitHub App Web 应用程序流程:请求用户身份时的登录参数是什么?
- python - 无法设置虚拟环境或查看是否安装了 Anaconda,无法访问 bash 文件夹,“找不到命令”
- docker - 码头工人:standard_init_linux.go:211
- c# - 在 ASP.NET MVC 中合并 dataTable 时没有返回数据
- makefile - 仅在某些文件更改时运行 Phony 目标
- spring - 如何访问 Spring Boot 中 application.properties 文件中定义的内容?
- python - “InSkillProduct”对象不可下标