【问题标题】:EditText background change color automatically when select an email选择电子邮件时,EditText 背景会自动更改颜色
【发布时间】:2020-11-20 14:34:27
【问题描述】:

当我启动我的应用程序时,电子邮件字段是好的,但是当我触摸它时,会出现一个包含一些电子邮件的下拉列表,当我选择其中一个时,电子邮件字段的背景颜色会突然改变。我不知道为什么会这样

editText字段before,带下拉,和after出现问题

这是editText的xml

<EditText
    android:id="@+id/editTextEmail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginTop="5dp"
    android:layout_marginEnd="8dp"
    android:layout_weight="1"
    android:ems="10"
    android:hint="@string/emailHint"
    android:inputType="textEmailAddress"
    style="@style/loginField"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/linearLayout4" />

还有@style/loginField

<style name="loginField">
    <item name="android:textColor">@color/gray400</item>
    <item name="android:textColorHint">@color/gray400</item>
    <item name="backgroundTint">@color/gray400</item>
    <item name="android:paddingTop">25dp</item>
</style>

也许我使用了错误的东西或者我遗漏了一些东西。希望有人可以帮忙

【问题讨论】:

    标签: android xml android-layout android-edittext


    【解决方案1】:

    颜色变化表明该字段已自动填充。

    您可以根据需要覆盖此颜色。

    <style name="AppTheme" parent="...">
        <item name="android:autofilledHighlight">#cccccc</item>
    </style>
    

    然后更改您的应用程序以使用这个新主题

    【讨论】:

      猜你喜欢
      • 2014-11-08
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-18
      • 2013-02-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多