在Android 12上,文件的扩展名被截断为长文件名



在Android 12上,问题可重复使用长文件名。从附件中可以看出,文件的扩展名是纵向剪切的。

问题是:当在一行中显示文件名时,并且android:ellipsize="middle",当setsetting "android:textAppearance="?attr/textAppearance/subtitle1 ">

时,文件名后缀不会完整显示。和布局

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FirstFragment">
<TextView
android:id="@+id/first_line_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:ellipsize="middle"
android:maxLines="1"
app:layout_constraintWidth="true"
android:text="RF_20210819NZ Herald - Breaking news, latest news, business, sport and entertainment - NZ Herald.url"
android:textAppearance="?attr/textAppearanceSubtitle1"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="RF_20210819NZ Herald - Breaking news, latest news, business, sport and entertainment - NZ Herald.url" />
<Button
android:id="@+id/button_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/first_line_text" />
</androidx.constraintlayout.widget.ConstraintLayout>

截图

删除android:maxLines="1"。它使文本停留在一行。这是如果你试图将文本移动到第二行。并删除android:ellipsize="middle",使声明的android:maxline="1",这实际上使文本留在一行,在中间被截断。

我也认为你不需要app:layout_constrainedWidth="true",因为你设置TextView的宽度为match_contraint已经,通过设置它为0

tools:text="..."用于测试您的UI,以查看它如何与不同长度的文本等工作。你不需要把android:text="..."tools:text="..."放在一起。

最新更新