android - 为什么不同手机的编辑文字样式不一样

标签 android android-studio android-edittext

我正在尝试在 android studio 中更改我的编辑文本样式。我在@drawable/edittext_design.xml 文件夹中更改了它。当我在 Nexus 5 上运行该应用程序时,它的运行与我预期的完全相同。然而,它在谷歌 Nexus S 手机上的运行有所不同。

这是它在 Nexus 5 上的样子:

nexus_5

这是它在 Nexus S 上的样子

nexus_s

我的 edit_design.xml 文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <padding
        android:top="5dp"
        android:bottom="5dp"
        android:left="7dp"
        />

    <stroke
        android:color="@color/orange"
        android:width="1dp"
        />

    <corners
        android:radius="4dp"
        />
</shape>

我的主要 xml 文件

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_Username"
        android:layout_marginTop="100dp"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="60dp"
        android:textColorHint="@color/light_blue"
        android:background="@drawable/edit_design"
        android:drawableLeft="@drawable/username_icon4"
        android:hint="Kullanıcı Adı"
        android:singleLine="true"
        android:textColor="@color/light_blue"/>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword"
        android:ems="10"
        android:id="@+id/et_Password"
        android:textColorHint="@color/light_blue"
        android:layout_marginLeft="60dp"
        android:layout_marginRight="60dp"
        android:layout_marginTop="7dp"
        android:drawableLeft="@drawable/username_icon3"
        android:hint="Şifre"
        android:singleLine="true"
        android:background="@drawable/edit_design"
        android:textColor="@color/light_blue"/>

我想将编辑文本的背景显示为白色,但在 Nexus S 中我面对的是黑色。是否与 API 级别相关?我该如何解决这个问题?

感谢您的帮助。

最佳答案

您几乎已经成功了,也可以尝试绘制白色背景,这样您就不再依赖于操作系统的默认颜色。

<solid android:color="@color/white"/>在你的edit_design.xml文件。

关于android - 为什么不同手机的编辑文字样式不一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36829733/

相关文章:

android - LG Nexus 5X 在 Windows 10 上的 Android Studio 中看不到

android - 地方 API 不工作。错误 : You must enable Billing on the Google Cloud Project

android - Jacoco 在 Gradle 7.0.2 和 Kotlin 1.5.10 上失败

java - EditText AdjustResize 强制内容不可见

c# - SignalR 连接线程与 Android

java - 拦截器没有被称为 retrofit2

Android WebView(Activity A) 即使用户转到 Activity B,音乐仍在播放

android - 将 android 库添加到 Studio/SDK 中的默认库列表

android - Kotlin 属性访问语法如何适用于 Java 类(即 EditText setText)?

Android:如何将光标向下移动到多行Edittext中的下一行?