V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
SilentOrFight
V2EX  ›  Android

澎湃 OS2(Android15)输入框文字不居中?

  •  
  •   SilentOrFight · 7 天前 · 1564 次点击

    设备:Redmi K60 系统:2.0.202.0.VMNCNXM Android 15

    在 Android stduio 新建一个 Android 项目,选择 java 语言,其他默认自动生成的代码不变,targetSdk 和 compileSdk 都是 35 (对应 Android 15 ),MainActivity 页面写了一个输入框,发现输入框的文字不居中(光标倒是居中了)。如果把 targetSdk 和 compileSdk 改为 34 就居中了,这是啥 bug 啊。这里有澎湃的攻城狮吗?

    xml 布局代码:

    <?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:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    
        <TextView
            android:id="@+id/a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="下面黄色区域是个居中的输入框"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <androidx.appcompat.widget.AppCompatEditText
            android:id="@+id/b"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_marginTop="40dp"
            android:layout_marginStart="37dp"
            android:layout_marginEnd="37dp"
            android:background="@android:color/holo_orange_light"
            android:gravity="center"
            android:hint="请输入文字"
            android:paddingStart="42dp"
            android:paddingEnd="42dp"
            android:textColor="#000000"
            android:textColorHint="#999999"
            android:textSize="15sp"
            app:layout_constraintTop_toBottomOf="@+id/a" />
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    

    设备测试截图: screenshot

    16 条回复    2025-07-28 18:27:40 +08:00
    hugozach
        1
    hugozach  
       7 天前
    那咋办? margin 设置个负值
    lscho
        2
    lscho  
       6 天前
    看起来不是居中的吗?
    Yserver
        3
    Yserver  
       5 天前
    @lscho 感觉高了一点
    Zy143L
        4
    Zy143L  
       5 天前 via Android
    是否和全面屏虚拟按键有冲突呢
    brsyrockss
        5
    brsyrockss  
       5 天前
    @lscho 你要是澎湃的工程师那太合理了
    lscho
        6
    lscho  
       5 天前
    @brsyrockss 尬了,op 说不居中,我一直在看左右居中,没想到是垂直没居中
    Nyeshuai
        7
    Nyeshuai  
       5 天前
    看样子是了,expo go 扫 react-native 文档 TextInput 就能复现,不光不居中,还可以上下滑动,一看就是魔改不到位,小米头头真是顶级草包,社区反馈也没响应。
    SilentOrFight
        8
    SilentOrFight  
    OP
       4 天前
    @Zy143L #4 应该不是,把项目改成 api34 ( Android 14 )编译,在红米 Android 15 系统上就是垂直居中的。
    而且同样的代码在 api35 ( Android 15 )编译,在原生 pixel 、vivo 上的 Android 15 系统上都是垂直居中的。
    控制变量下,只有澎湃 OS 出现显示错误。
    SilentOrFight
        9
    SilentOrFight  
    OP
       4 天前
    @lscho #6 是我的锅,没说清楚
    SilentOrFight
        10
    SilentOrFight  
    OP
       4 天前
    @hugozach #1 不是,只有澎湃出问题。。。我不可能给它的错误去适配
    SilentOrFight
        11
    SilentOrFight  
    OP
       4 天前
    @Nyeshuai #7 自从重心往造车去了,系统真的越来越差了(红米、vivo 双持的真实体验)
    entro
        12
    entro  
       4 天前
    是的,之前用 m3 发现光标垂直不居中,研究了一下午,才发现只有 hyperos 有这个问题
    SilentOrFight
        13
    SilentOrFight  
    OP
       4 天前
    @Zy143L #4 哇擦,好像真的是虚拟键的问题!!!改成全面屏手势就好了
    SilentOrFight
        14
    SilentOrFight  
    OP
       4 天前
    @SilentOrFight #13 🌶︎🐔澎湃
    Nyeshuai
        15
    Nyeshuai  
       4 天前
    @SilentOrFight #11 说不定以前就是这样呢, 只不过现在外显了
    SilentOrFight
        16
    SilentOrFight  
    OP
       4 天前
    @entro #12 搞不懂也改不动,就这🌶︎🐔澎湃会这样
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2340 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 19ms · UTC 15:59 · PVG 23:59 · LAX 08:59 · JFK 11:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.