I want to change Material TextInputEditText's bubble and cursor color. I tried colorAccent, android:textCursorDrawable these are not working correctly.
The material attribute color colorControlActivated do the magic. You have to create a style for your TextInputLayout.
eg:
<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>
Then you have to apply this style in the theme attribute of control:
<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>
只需在应用程序主题(白天/黑夜)中应用colorControlActivated ,所有 Material TextInputEditField 都将具有更改的光标颜色
<item name="android:colorControlActivated">@color/green</item>
You have to use following attributes:
<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>
To know more about : Setting up a Material Components theme for Android
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.