You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 12下配置ellipsize=middle的TextView用Subtitle1样式时长文件名后缀截断

Android 12 长文件名显示异常问题说明

在Android 12系统上可复现长文件名显示异常问题:竖屏场景下,当需要将文件名单行展示、且配置android:ellipsize="middle"属性时,为TextView设置android:textAppearance="?attr/textAppearanceSubtitle1"会导致文件名扩展名显示不全。

对应布局代码

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

内容的提问来源于stack exchange,提问作者Andy Wu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 08:15:02