33

I need to set the hint of a EditText as italic style, but I can't find any place how to do it.

Some one here has a clue how to do it or do I have to accept that is impossible?

lagos
  • 1,918
  • 3
  • 17
  • 25

4 Answers4

84

Inside strings.xml

 <string name="hint1"><i>Your hint here</i></string>

In your .xml file

  <EditText android:hint="@string/hint1" />
Deepzz
  • 4,489
  • 1
  • 26
  • 52
18

Add one string value in Strings.xml as <i>your hint here</i> and try to set it in your EditText in the xml

Solution 2:

if(youredittext.getText().toString().length()==0)
{
    youredittext.setTypeface(null,Typeface.ITALIC);
}
else
{
youredittext.setTypeface(null,Typeface.NORMAL);
}
Ashu Kumar
  • 802
  • 19
  • 36
Pragnani
  • 19,755
  • 6
  • 46
  • 74
6

Try out as below:

edittext.setHint(Html.fromHtml("<small><i>" + "Text Hint Here" + "</i></small>"));
Deepzz
  • 4,489
  • 1
  • 26
  • 52
GrIsHu
  • 28,433
  • 10
  • 61
  • 99
1

In your xml, you can set a TextStyle. This TextStyle is applicable on your text and your hint.

<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@Your text here"
android:textStyle="italic"/>
JND
  • 173
  • 1
  • 12