This is the solution. I have created a custom EditText with the custom font.
package com.example.customcontrols;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.EditText;
public class MyEditTextItalic extends EditText {
/*
* Caches typefaces based on their file path and name, so that they don't
* have to be created every time when they are referenced.
*/
private static Typeface mTypeface;
public MyEditTextItalic(Context context) {
super(context);
setTypeface(context);
}
public MyEditTextItalic(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setTypeface(context);
}
public MyEditTextItalic(Context context, AttributeSet attrs) {
super(context, attrs);
setTypeface(context);
}
// intercept Typeface change and set it with our custom font
public void setTypeface(Context context) {
if (mTypeface == null) {
mTypeface = Typeface.createFromAsset(context.getAssets(),
"fonts/HelveticaNeue-Bold.otf");
}
super.setTypeface(mTypeface,Typeface.ITALIC);
}
}
It is very important not create typeface italic because isn't show correctly, for use italic when set the font use super.setTypeface(mTypeface,Typeface.ITALIC);
in .xml
<com.example.customcontrols.MyEditTextItalic
android:id="@+id/edit_txt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/rectangle_white"
android:drawableLeft="@drawable/ic_key"
android:drawablePadding="10dp"
android:ems="10"
android:hint="@string/login_password_placeholder"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:padding="10dp"
android:textColor="@color/black"
android:textCursorDrawable="@null"
android:textStyle="bold|italic"
android:textColorHint="@color/color_form_login_text"
android:textSize="17sp" />