Android TextInputLayout和TextInputEditText光标颜色问题

时间:2020-08-28 15:04:07

标签: android android-theme android-styles material-components-android android-textinputlayout

enter image description here Problem

我有这个问题,在xxx是紫罗兰色的光标之后,我想知道该放置光标的名称,我想更改颜色以匹配我的主题。我阅读了许多论坛和文档,我发现的唯一是cursorDrawable,但事实并非如此。请以正确的名称帮助我或进行解决。 谢谢 PD:东西的紫罗兰色不是我的风格或颜色。

1 个答案:

答案 0 :(得分:3)

颜色基于 colorPrimary

如果要覆盖colorPrimary,可以使用:

  <com.google.android.material.textfield.TextInputLayout                
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"
    ....>

具有:

<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
    <item name="colorPrimary">@color/...</item>
</style>

enter image description here

如果只想覆盖游标,则可以使用:

<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
    <item name="colorControlActivated">@color/...</item>
</style>

enter image description here

enter image description here