3 回答
TA贡献1848条经验 获得超10个赞
材质属性颜色colorControlActivated具有魔力。您必须为 TextInputLayout 创建样式。
例如:
<style name="TextInputLayoutAppearance" parent="Widget.Design.TextInputLayout">
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/red</item>
<item name="colorControlHighlight">@color/blue</item>
</style>
然后你必须在控件的主题属性中应用这个样式:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/lblObservaciones"
android:theme="@style/TextInputLayoutAppearance"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxStrokeColor="@color/blue"
app:hintTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:hintTextColor="@color/blue">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/comments"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="top"
android:inputType="textMultiLine"
android:maxLength="200" />
</com.google.android.material.textfield.TextInputLayout>
TA贡献1853条经验 获得超18个赞
只需在应用程序主题(日/夜)中应用colorControlActivated,所有 Material TextInputEditField 将具有更改的光标颜色
<item name="android:colorControlActivated">@color/green</item>
TA贡献1850条经验 获得超11个赞
您必须使用以下属性:
<style name="AppTheme" parent="Theme.MaterialComponents.Light"> <item name="colorPrimary">#212121</item> <item name="colorPrimaryVariant">#000000</item> <item name="colorOnPrimary">#FFFFFF</item> <item name="colorSecondary">#2962FF</item> <item name="colorSecondaryVariant">#0039CB</item> <item name="colorOnSecondary">#FFFFFF</item> <item name="colorError">#F44336</item> <item name="colorOnError">#FFFFFF</item> <item name="colorSurface">#FFFFFF</item> <item name="colorOnSurface">#212121</item> <item name="android:colorBackground">@color/background</item> <item name="colorOnBackground">#212121</item></style><color name="background">#FAFAFA</color>
添加回答
举报