MaterialSearchBar icon indicating copy to clipboard operation
MaterialSearchBar copied to clipboard

Unable to change cursor color

Open r3dm4n opened this issue 5 years ago • 6 comments

I have tried to change the cursor color with a custom theme, but it's always white. Any suggestions ?

r3dm4n avatar Sep 10 '18 18:09 r3dm4n

I have the same issue

UnsignedInt8 avatar Dec 09 '18 07:12 UnsignedInt8

E/ContentValues: init: 
    com.mancj.materialsearchbar.EditTextStyleHelper$EditTextStyleChangeError: Error applying changes to androidx.appcompat.widget.AppCompatEditText{355d4fb VFED..CL. ......I. 0,0-0,0 #7f0a0655 app:id/mt_editText}
        at com.mancj.materialsearchbar.EditTextStyleHelper.apply(EditTextStyleHelper.java:125)
        at com.mancj.materialsearchbar.EditTextStyleHelper.applyChanges(EditTextStyleHelper.java:40)
        at com.mancj.materialsearchbar.MaterialSearchBar.setupSearchEditText(MaterialSearchBar.java:314)
        at com.mancj.materialsearchbar.MaterialSearchBar.postSetup(MaterialSearchBar.java:278)
        at com.mancj.materialsearchbar.MaterialSearchBar.init(MaterialSearchBar.java:220)
        at com.mancj.materialsearchbar.MaterialSearchBar.<init>(MaterialSearchBar.java:123)
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
  /**
     * Setup editText coloring and drawables
     */
    private void setupSearchEditText() {
        try {
            EditTextStyleHelper.applyChanges(this.searchEdit, this.textCursorColor, this.leftTextSelectorTint, this.rightTextSelectorTint, this.middleTextSelectorTint,
                    this.leftTextSelectorRes, this.rightTextSelectorRes, this.middleTextSelectorRes, this.textSelectorTintEnabled);
        } catch (EditTextStyleHelper.EditTextStyleChangeError e) {
            Log.e(TAG, "init: ", e);
        }
......

I guess the problem is here.

UnsignedInt8 avatar Dec 09 '18 07:12 UnsignedInt8

I have the same problem, too. mt_textCursorTint does not change the color, and it's alway white.

stdrc avatar May 18 '19 12:05 stdrc

also meet this problem,how to resolve

yanhu0614 avatar Jun 05 '19 09:06 yanhu0614

I managed to change via code

private var editText: EditText? = null

editText = etSearch.findViewById(R.id.mt_editText)

try { val f = TextView::class.java.getDeclaredField("mCursorDrawableRes") f.isAccessible = true f.set(editText, R.drawable.home_search_cursor); } catch (e: Exception) { }

home_search_cursor.xml

karthikkolanji avatar Jul 22 '19 06:07 karthikkolanji

Fix for the issue! Create a xml file in drawable folders called color_cursor.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ff000000" />
<size android:width="1dp" />

change the color in xml to whatever color you want for the cursor.

mayankagarwal09 avatar Aug 27 '19 15:08 mayankagarwal09