How to Change Cursor Color Without Changing Text Color

How to change cursor color without changing text color?

You can make a custom one.

input, textarea {
cursor: url(cursor.cur);
}

Set EditText cursor color

Setting the android:textCursorDrawable attribute to @null should result in the use of android:textColor as the cursor color.

Attribute "textCursorDrawable" is available in API level 12 and higher

Input cursor color

Changing the colour when entering content is easy:

input:focus { color: yellow }

not supported by IE7 and lower. Compatibility table here.

Changing the cursor colour specifically is impossible as far as I know. It will usually take on the text content's colour which should be fine in most cases.

Changing cursor color on UISearchBar without changing tintColor

Set your tint color to the color you want the cancel button to be and then use the UIAppearance Protocol to change the tint color on the text field to be the color you wish the cursor to be. Ex:

[self.searchBar setTintColor:[UIColor whiteColor]];                
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:[UIColor darkGrayColor]];

How do I set text background color without changing cursor location?

To preserve the previous caret position and selection too:


... Call to suspend drawing here

var start = richTextBox1.SelectionStart;
var len = richTextBox1.SelectionLength;

richTextBox1.Select(10, 3);
richTextBox1.SelectionBackColor = Color.White;

richTextBox1.SelectionStart = start;
richTextBox1.SelectionLength = len;

... Call to resume drawing here

To prevent flicking check the solution provided in this post: https://stackoverflow.com/a/487757/6630084


TextBoxBase.SelectionStart Property

TextBoxBase.SelectionLength Property

How to change React Native cursor color?

Yes, we can do it by setting tint color.

In AppDelegate.m of project.

Adding the below code between self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; and [self.window makeKeyAndVisible];, you can change the global tint color.

self.window.tintColor = [UIColor redColor]; // Here is your color.

Or, adding the below code after [self.window makeKeyAndVisible];, you can change the tint color of TextInput/UITextField.

[[UITextField appearance] setTintColor:[UIColor redColor]];

Nothing happens when you change the UITextView's tint color.

And I couldn't find a way to implement it with a style of JaveScript.

How to change the floating label color of TextInputLayout and the cursor, without changing `colorAccent` in `AppTheme`

Create a custom style like this:

    <style name="myInputText">
<item name="android:textColor">@color/myColor</item>
<item name="android:textSize">@dimen/text_size</item>
...
</style>

Now, you can directly use this in TextInputLayout, no need to provide any parent in style or change your app theme.

<android.support.design.widget.TextInputLayout
android:textColorHint="@color/myColor"
app:hintTextAppearance="@style/myInputText"
android:layout_width="match_parent"
android:layout_height="50dp">

EDIT

This only changes the color of the floating label, not the cursor. To also change the cursor color, you need to create a drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:height="10dp"
android:width="2dp"/>
<solid android:color="@color/myColor"/>
</shape>

and add it to the style you use for the TextInputEditText, not the TextInputLayout.

<style name="Settings.TextInputEditText">
...
<item name="android:textCursorDrawable">@drawable/cursor</item>
</style>

How to change the text color after touch?

button:hover p{
color: red!important; // change the color you want
}


Related Topics



Leave a reply



Submit