TextInputEditText气泡颜色的问题

时间:2020-05-14 15:51:58

标签: android android-layout android-textinputedittext

我在使用TextInputEditText时遇到问题,我想更改气泡的颜色。
TextInputEditText
Xml布局文件:

<com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MyTheme.TextInputLayout.OutlinedBox"
        android:id="@+id/textInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="50dp"
        android:layout_marginTop="50dp"
        android:layout_marginEnd="50dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textViewLogin">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email"
            android:inputType="textEmailAddress"
            android:textColorHint="@color/white" />
    </com.google.android.material.textfield.TextInputLayout>

我的风格:

<style name="Widget.MyTheme.TextInputLayout.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <item name="boxStrokeColor">@color/white</item>
    <item name="hintTextColor">@color/white</item>
</style>

我在这里尝试添加

 <item name="colorControlActivated">@color/white</item>
    <item name="android:colorControlActivated">@color/white</item>
    <item name="android:colorAccent">@color/white</item>
    <item name="colorAccent">@color/white</item>

但是这些都不起作用。

1 个答案:

答案 0 :(得分:1)

尝试此示例

<com.google.android.material.textfield.TextInputLayout
    ..
    android:id="@+id/textInputLayout"
    android:theme="@style/TextInputLayoutAppearance" // add this line
    ..
   >

    <com.google.android.material.textfield.TextInputEditText
       ...
         android:id="@+id/email"
       ..
    />
</com.google.android.material.textfield.TextInputLayout>

styles.xml

 <style name="TextInputLayoutAppearance" parent="Widget.Design.TextInputLayout">
    <item name="colorControlActivated">@color/blue</item>
</style>

还请检查this以确定样式主题