![]() Get the drawable and set a color filterĭrawable cursorPipe = ContextCompat. How to Change programmatically Edittext Cursor Color in android Ask Question Asked 8 years, 9 months ago Modified 1 year, 2 months ago Viewed 35k times 30 In android we can change the cursor color via: android:textCursorDrawable'drawable/blackcolorcursor'. Object editor = field.get(this._inputEditText) Int drawableResId = field.getInt(this._inputEditText) įield = ("mEditor") ![]() So, I wrote the following code // Get the cursor resource idįield field = ("mCursorDrawableRes") change edittext cursor color android user-interface 73,330 Solution 1 In your EditText properties, there is an attribute android:textCursorDrawable Now set it to null like, android:textCursorDrawable'null' So now your EditText Cursor is same as your EditText TextColor. I don't know why, but this class can't be referred to my project, but that's not a problem, I can get a reference of it through reflection too. Looking through the SDK 28 files, I found the name of the Field that I want to change, and it is "mDrawableForCursor", this field exists inside of the Editor class. I'm trying to change the color of the EditText cursor at runtime using reflection. With this in mind, I can proceed to the real problem. ![]() I'm using an emulator with Android API 28 x86, and my project target/compile SDK version is 28.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |