【问题标题】:Android TextInputLayout and TextInputEditText cursor color problemAndroid TextInputLayout和TextInputEditText光标颜色问题
【发布时间】:2020-08-28 15:04:07
【问题描述】:

我有这个问题,在xxx是紫色光标之后,我想知道那个下拉光标的名称,我想改变颜色以匹配我的主题。我阅读了许多论坛和文档,我发现的唯一一个是 cursorDrawable,但不是这样。请帮助我正确搜索名称或解决方案。 谢谢 PD:那东西的紫色不是我的风格或颜色。

【问题讨论】:

  • 请发布您的代码

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


【解决方案1】:

颜色基于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>

如果你只想覆盖你可以使用的光标:

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

【讨论】:

  • 谢谢,但我的意思是光标下方的水滴,这就是我需要改变的地方。我添加了另一张图片,显示了我的意思
  • @GastonFassiLavalle 水滴与光标颜色相同。
  • 谢谢,现在我需要找到我尝试的颜色在哪里 #000#000#000 仍然是紫色而不是黑色。我会尝试在样式中覆盖,但我想知道紫色是从哪里来的
  • @GastonFassiLavalle 紫色 (#6200EE) 是由 Material Theme 定义的默认颜色。在您的styles.xml 中,只需在您的应用主题中添加colorPrimary 属性。比如:&lt;style name="AppTheme" parent="Theme.MaterialComponents.DayNight"&gt; &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
  • 谢谢它的工作,我正在寻找另一种方式,但最好覆盖。非常感谢。
猜你喜欢
  • 2021-08-25
  • 2020-09-28
  • 2019-07-15
  • 1970-01-01
  • 1970-01-01
  • 2019-04-27
  • 1970-01-01
  • 2016-10-16
  • 2019-02-09
相关资源
最近更新 更多