Where does the green color comes from? I've tried changing the accentColor
attribute, which works in other parts of the app, but not here.
Screenshot from app in Lollipop.
How can I change the colors of:
And maybe some tips for the future... How did you find out? I've been coming across all these confusing color/styling problems. Is there some kind of list somewhere that tells me, which default color or attribute that I need to overwrite for a certain component?
For changing the handle color you can do as specified here you do it using style as
<style name="MyCustomTheme" parent="@style/MyNotSoCustomTheme">
<item name="android:textSelectHandle">@drawable/text_select_handle_middle</item>
<item name="android:textSelectHandleLeft">@drawable/text_select_handle_left</item>
<item name="android:textSelectHandleRight">@drawable/text_select_handle_right</item>
</style>
For doing it programmatically check same question another reply here which is done using reflection
try {
final Field fEditor = TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
final Object editor = fEditor.get(editText);
final Field fSelectHandleLeft = editor.getClass().getDeclaredField("mSelectHandleLeft");
final Field fSelectHandleRight = editor.getClass().getDeclaredField("mSelectHandleRight");
final Field fSelectHandleCenter = editor.getClass().getDeclaredField("mSelectHandleCenter");
fSelectHandleLeft.setAccessible(true);
fSelectHandleRight.setAccessible(true);
fSelectHandleCenter.setAccessible(true);
final Resources res = context.getResources();
fSelectHandleLeft.set(editor, res.getDrawable(R.drawable.text_select_handle_left));
fSelectHandleRight.set(editor, res.getDrawable(R.drawable.text_select_handle_right));
fSelectHandleCenter.set(editor, res.getDrawable(R.drawable.text_select_handle_middle));
} catch (final Exception ignored) {
}
For changing the selected text color you can set textColorHighlight
in xml as
android:textColorHighlight="#ff0000"
through style you can do as
<item name="android:textColorHighlight">@color/m_highlight_blue</item>