设备: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>
设备测试截图:
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.