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

Android 14+One UI 6三星设备TextView消失问题排查请求

三星One UI 6(Android 14)上TextView消失的布局问题排查与修复

核心问题分析

你的布局在三星设备上出现TextView消失,主要是以下几个布局写法的隐患在One UI的渲染逻辑下被放大:

1. 无约束的顶部嵌套ConstraintLayout遮挡内容

顶部带@drawable/background_portrait的ConstraintLayout,仅设置了tools:layout_editor_absoluteX/Y(仅编辑器预览用,实际运行无效),未添加任何运行时约束(比如app:layout_constraintTop_toTopOf="parent")。这会导致该布局运行时位置、大小不可控,大概率会覆盖下方TextView——尤其是三星设备的布局渲染优先级会让这个无约束View抢占绘制层级。

2. 固定marginTop的定位适配性差

顶部ImageView和TextView仅靠android:layout_marginTop + app:layout_constraintTop_toTopOf="parent"定位,未建立元素间相对约束(比如让副标题依赖标题底部)。这种固定dp值的margin在不同屏幕尺寸/密度设备(如三星高屏占比机型)上会出现位置偏移,甚至被下方ScrollView遮挡。

3. ScrollView布局参数冲突

ScrollView同时设置android:layout_height="match_parent"和android:layout_marginTop="351dp",配合app:layout_constraintTop_toTopOf="parent"会导致:ScrollView顶部从父布局Top+351dp开始,但高度铺满屏幕,底部超出显示区域;部分设备上ScrollView会向上延伸,直接遮挡上方TextView。

4. 固定宽高的TextView因字体渲染问题消失

第二个TextView设置了固定宽度159dp和高度44dp,One UI对sans-serif-light字体的渲染逻辑和其他厂商不同,文字超出宽度后会被默认隐藏(未设置android:ellipsize),看起来像是消失了。


修复方案

修改后的布局如下,解决上述所有问题:

<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:id="@+id/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <!-- 修复:给背景布局添加运行时约束,固定顶部位置 -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="253dp"
        android:background="@drawable/background_portrait"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">
    </androidx.constraintlayout.widget.ConstraintLayout>

    <com.mikhaellopez.circularimageview.CircularImageView
        android:id="@+id/circularImageView"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="200dp"
        android:src="@drawable/stradislogo"
        app:civ_border_color="@color/semiTransparentWhite"
        app:civ_border_width="10dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <!-- 修复:取消固定宽度,改用wrap_content;建立与ImageView的相对约束 -->
    <TextView
        android:id="@+id/tv_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:fontFamily="sans-serif-light"
        android:text="Anfahrt"
        android:textColor="@android:color/black"
        android:textSize="30sp"
        app:layout_constraintStart_toEndOf="@+id/circularImageView"
        app:layout_constraintTop_toTopOf="@+id/circularImageView" />

    <!-- 修复:取消固定宽高,设置ellipsize避免文字溢出;建立与标题的相对约束 -->
    <TextView
        android:id="@+id/tv_subtitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="8dp"
        android:fontFamily="sans-serif-light"
        android:text="Plasmaspende-Zentrum in Egelsbach"
        android:textSize="14sp"
        android:ellipsize="end"
        android:maxLines="2"
        app:layout_constraintStart_toEndOf="@+id/circularImageView"
        app:layout_constraintTop_toBottomOf="@+id/tv_title" />

    <!-- 修复:让ScrollView依赖副标题底部,用0dp自动填充剩余空间,避免遮挡 -->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="16dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_subtitle"
        app:layout_constraintBottom_toBottomOf="parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.google.android.material.button.MaterialButton
                android:id="@+id/routenplanung"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="16dp"
                android:layout_marginEnd="10dp"
                android:layout_marginBottom="10dp"
                android:backgroundTint="@color/colorAccent"
                android:text="Routenplanung"
                android:textColor="@color/white"
                app:cornerRadius="20dp" />

            <!-- Map View -->
            <TextView
                android:id="@+id/textView6"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="10dp"
                android:text="@string/stradis_med_gmbh_anfahrt" />

            <fragment
                android:id="@+id/mapFragment"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginTop="16dp" />

        </LinearLayout>

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

关键修改点说明

  • 给顶部背景布局添加运行时约束,确保它仅占据顶部253dp区域,不会乱跑遮挡其他View
  • 把标题和副标题改为相对约束(依赖CircularImageView和彼此),替代固定marginTop,适配不同屏幕尺寸
  • 取消TextView的固定宽高,添加ellipsize和maxLines,避免One UI字体渲染导致的文字溢出隐藏
  • 修改ScrollView参数:用layout_height="0dp"配合上下约束,让它自动填充剩余空间,不再遮挡上方内容

内容的提问来源于stack exchange,提问作者Simon Giesen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 22:24:56