【问题标题】:EditText tint line color not changing in night modeEditText 色调线颜色在夜间模式下不改变
【发布时间】:2021-07-09 12:11:20
【问题描述】:

我的布局中有EditText

<EditText
 android:id="@+id/etMarks1"
 style="@style/Marks"/>

theme.xml

    <style name="Marks" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <item name="android:layout_weight">15</item>
        <item name="android:ems">1</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:inputType">number</item>
        <item name="android:textSize">18sp</item>
        <item name="android:gravity">center</item>
    </style>

色调线的颜色默认是黑色的,在夜间模式下应该会改变它的颜色,但它不会改变。

我尝试在 theme.xml(nignt) 中手动定义色调线颜色

<item name ="backgroundTint">@color/white</item>
<item name="colorControlNormal">@color/white</item>

但是,它不起作用, 有什么解决办法吗?

【问题讨论】:

  • EditText 的默认父样式为 Widget.AppCompat.EditText。如果你想覆盖 colorControlNormal 你必须使用 android:theme 而不是 style
  • 是的,现在我在 theme.xml(night) 中定义了 colorControlNormal 并且工作正常,谢谢

标签: android material-components-android android-dark-theme


【解决方案1】:

已解决
我在应用程序的默认主题中定义了colorControlNormal,工作正常。

【讨论】:

    猜你喜欢
    • 2020-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-26
    相关资源
    最近更新 更多