如何更改材质TextInputLayout OutlinedBox散焦的颜色 [英] How to change material TextInputLayout OutlinedBox unfocused Color
本文介绍了如何更改材质TextInputLayout OutlinedBox散焦的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有OutlinedBox TextInputLayout,并且我想在editText的非聚焦模式下更改框的颜色.
I have an OutlinedBox TextInputLayout and I want to change the box color in the unfocused mode of editText.
我该怎么做?
推荐答案
在主题中添加colorOnSurface
属性并分配所需的任何颜色
In the theme Add colorOnSurface
attribute and assign any color you want
<style name="Apptheme"
parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- General theme colors -->
<item name="colorPrimary">@color/material_green_500</item>
<item name="colorSecondary">@color/material_green_600</item>
<item name="colorAccent">@color/illiniColorAccent</item>
<item name="colorOnSurface">@color/blue</item><!--inputtext unfocused color-->
</style>
结果是:
colorPrimary
也是聚焦状态的颜色.
The result is:
Also colorPrimary
is the color of focused state.
您可以自定义的其他属性是:
Other attributes you can customize are:
<item name="enforceMaterialTheme">true</item>
<item name="enforceTextAppearance">true</item>
<item name="boxBackgroundMode">outline</item>
<item name="boxBackgroundColor">@null</item>
<item name="endIconTint">@color/mtrl_outline_end_icon_tint</item>
<item name="boxCollapsedPaddingTop">0dp</item>
<item name="boxCornerRadiusTopStart">@dimen/mtrl_textinput_box_corner_radius_medium</item>
<item name="boxCornerRadiusTopEnd">@dimen/mtrl_textinput_box_corner_radius_medium</item>
<item name="boxCornerRadiusBottomEnd">@dimen/mtrl_textinput_box_corner_radius_medium</item>
<item name="boxCornerRadiusBottomStart">@dimen/mtrl_textinput_box_corner_radius_medium</item>
<item name="boxStrokeColor">@color/mtrl_outlined_stroke_color</item>
<item name="counterTextAppearance">?attr/textAppearanceCaption</item>
<item name="counterOverflowTextAppearance">?attr/textAppearanceCaption</item>
<item name="errorTextAppearance">?attr/textAppearanceCaption</item>
<item name="helperTextTextAppearance">?attr/textAppearanceCaption</item>
<item name="hintTextAppearance">?attr/textAppearanceCaption</item>
<item name="counterTextColor">@color/mtrl_indicator_text_color</item>
<item name="counterOverflowTextColor">@color/mtrl_error</item>
<item name="errorTextColor">@color/mtrl_error</item>
<item name="helperTextTextColor">@color/mtrl_indicator_text_color</item>
<!-- The color of the label when it is collapsed and the text field is active -->
<item name="hintTextColor">?attr/colorPrimary</item>
<!-- The color of the label in all other text field states (such as resting and disabled) -->
<item name="android:textColorHint">@color/mtrl_indicator_text_color</item>
<item name="shapeAppearance">?attr/shapeAppearanceSmallComponent</item>
<item name="shapeAppearanceOverlay">@null</item>
这篇关于如何更改材质TextInputLayout OutlinedBox散焦的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文