Change focus color EditText?

How to change the color of an EditText when focusing? In the emulator, it is blue when it is focused, and I see no way to change it from an XML layout or programmatically. I canโ€™t understand how to change the focus color of a different kind, as well as buttons and spinning. The selected color of the EditText blue

+4
source share
1 answer
yourEditText.setOnFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { if (v == yourEditText) { if (hasFocus) { yourEditText..setTextColor(Color.RED); } else { } } } }); 

use a focus listener for this (button, etc.)

EDIT You must use XML and set the view background for this

  <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:color="yourDesiredcolorcode" /> <!-- pressed --> <item android:state_focused="true" android:color="yourDesiredcolorcode" /> <!-- focused --> <item android:color="yourDesiredcolorcode" /> <!-- default --> </selector> 

Greetings

+1
source

All Articles