Android TextInputLayout 和 TextInputEditText 光标颜色问题

Gas*_*lle 1 android android-theme android-styles android-textinputlayout material-components-android

在此处输入图片说明问题

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

Gab*_*tti 8

颜色基于colorPrimary.

如果你想覆盖 colorPrimary 你可以使用:

  <com.google.android.material.textfield.TextInputLayout                
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:theme="@style/ThemeOverlay.AppTheme.TextInputEditText.Outlined"
    ....>
Run Code Online (Sandbox Code Playgroud)

和:

<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
    <item name="colorPrimary">@color/...</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

如果您只想覆盖光标,您可以使用:

<style name="ThemeOverlay.AppTheme.TextInputEditText.Outlined" parent="">
    <item name="colorControlActivated">@color/...</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

在此处输入图片说明