hi am using EditText and it's hint is ' Password(at least 12 char) ' both the text are in different size ie 'Password' and '(at least 12 char)' how can i set this ?
Asked
Active
Viewed 1.1k times
2
-
you want set hint on edittext..? – Niranj Patel Mar 05 '11 at 11:23
-
yes, but the hint sentence contain word with different size – Bytecode Mar 05 '11 at 11:38
-
I m not sure but i think it is not possible. may be change color of hint.. – Niranj Patel Mar 05 '11 at 12:37
3 Answers
16
I have found a way to do this by setting
editTextPassword.setHint(Html.fromHtml("<font size=\"16\">" + "Password " + "</font>" + "<small>" + "(at least 12 charcters)" + "</small>" ));
and it work for me.

Abdelrahman Elkady
- 2,518
- 2
- 21
- 30

Bytecode
- 6,551
- 16
- 54
- 101
1
editText.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
@Override
public void onTextChanged(CharSequence arg0, int start, int before, int count) {
if (arg0.length() == 0) {
// No entered text so will show hint
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mHintTextSize);
} else {
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mRealTextSize);
}
}
});
And in onCreate
you also need to change text size according to your requirement.

Kevin Cruijssen
- 9,153
- 9
- 61
- 135

Narendra
- 1,010
- 1
- 12
- 11
0
alternatively, changing the size of the text will affect the size of the hint...
<EditText
...
android:textSize="14dp"/>

Jeremie D
- 4,145
- 1
- 35
- 41