EditText 在提供的照片中为此指针使用颜色重音

EditText uses color Accent for this pointer in the photo provided

我发现 EditText 指针使用默认颜色 Accent,那么如何更改它的颜色?

在我的 EditText 上,如果我插入 android:theme= @style/mytheme,它会起作用,但当我使用 style = "@style/mytheme" 时,它不会起作用。

问题是当我使用 android:theme= @style/mythemeEditText 提示消失了。

如何使用自定义样式更改它的颜色?

这是我的代码:

 <EditText
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:hint="@string/cap"
        android:background="@drawable/input_shape"
        android:drawableStart="@drawable/search"
        android:drawableLeft="@drawable/search"
        android:inputType="number"
        android:id="@+id/capInput"
        style="@style/MyEditText"/>

和自定义样式:

    <style name="MyEditText" parent="@android:style/Widget.EditText">
    <item name="colorAccent">@color/notification_material_background_media_default_color</item>
</style>

提前致谢!

style 属性改为 EditText,尝试更改为 android 主题属性,如下所示:

android:theme="@style/MyEditText"

EditText(复制粘贴)Bouble 使用您应用主题的 colorAccent 作为其颜色,您可以更改应用主题的 colorAccent,或者您可以创建新样式并将其设置为 EditText 主题

<style name="CustomEditText" >
    <item name="colorAccent">@color/your_favourite_color</item>
</style>

并将其设置为您的 EditText:

<EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Your Hint"
        android:theme="@style/CustomEditText"
       />

如果你想使用你的appTheme的其他属性,你可以将它设置为父样式并改变它的colorAccent

<style name="CustomEditText" parent="AppTheme">
    <item name="colorAccent">@color/your_favourite_color</item>
</style>