Change the cursor color via styling
See original GitHub issueLooks like the TextInputLayout
and TextInputEditTextLayout
are defaulting the cursor (and cursor bubble) color to primary color. I tested it by switching the global primary color of the app and it works. However, when I try to create a theme for that specific view and override the primary color, it doesn’t work.
<style name="Widget.AppTheme.TextInputEditText.Dense" parent="Widget.MaterialComponents.TextInputEditText.FilledBox.Dense">
<item name="colorPrimary">@color/orange</item>
</style>
<com.google.android.material.textfield.TextInputLayout
app:hintEnabled="false"
app:hintAnimationEnabled="false"
android:id="@+id/f_login_email_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_default"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/f_login_subheader">
<com.google.android.material.textfield.TextInputEditText
style="@style/Widget.AppTheme.TextInputEditText.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:ems="10"
android:textSize="@dimen/text_size_text_entry"
android:hint="@string/login_email_hint"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
Could somebody help with this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:22 (6 by maintainers)
Top Results From Across the Web
How to Change the Cursor Color in CSS | SamanthaMing.com
Use the caret-color to change the color of the cursor. Now you can change the color to match the theme of ... The...
Read more >caret-color - CSS: Cascading Style Sheets - MDN Web Docs
The caret-color CSS property sets the color of the insertion caret, the visible marker where the next character typed will be inserted.
Read more >How to Change Cursor on Hover in CSS - W3docs
To specify the cursor appearance, use the CSS cursor property, which is used to change the mouse cursor type on elements. It can...
Read more >How to change cursor color without changing text color?
Yes it's easy. Set your font color normally then use a custom cursor. http://beradrian.wordpress.
Read more >CSS caret-color property - W3Schools
Definition and Usage. The caret-color property specifies the color of the cursor (caret) in inputs, textareas, or any element that is editable.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi everyone I share my way of setting the OutlinedBox style.
First of all, I am using version 1.1.0
implementation 'com.google.android.material:material:1.1.0'
Just like you mentioned @dsn5ft , I create a style by referencing the style TextInputEditText.OutlinedBox
In my case I use a style for my TextInputLayout, I add android:theme with the created style
and I add the style in the component
and that’s it, the color change to the cursor works
regards.
The reason why using
android:theme
works is becausecolorControlActivated
is a theme attribute, as opposed to a specific component attribute (e.g.,hintTextColor
).One way you could customize a global theme attribute but only have that customization apply to a specific component is to use our
materialThemeOverlay
functionality. E.g.:Create a theme overlay that customizes
colorControlActivated
:Create a
TextInputLayout
style that uses the theme overlay:Set the
TextInputLayout
style as the default in your app theme: