The proposed selector solution by windyzboy doesn't work for EditTexts with centered text, because the cursor stays behind the transparent hint text instead of moving to the center.
A good way without polluting your code is to make a custom EditText, since you probably need the same style in the whole application. That way you can avoid adding checks for each EditText separately.
public class HideHintEditText extends EditText {
CharSequence hint;
public HideHintEditText(Context context) {
super(context);
hint = this.getHint();
}
public HideHintEditText(Context context, AttributeSet attrs) {
super(context, attrs);
hint = this.getHint();
}
public HideHintEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
hint = this.getHint();
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
this.setHint(focused ? "" : hint);
}
}