public class CustomTextView extends TextView {
Context context;
public CustomTextView (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.context = context;
}
public CustomTextView (Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public CustomTextView (Context context) {
super(context);
this.context = context;
}
public void setTypeface(Typeface tf, int style) {
if (style == Typeface.NORMAL) {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/HelveticaNeue.ttf")/*
* ,
* -
* 1
*/);
} else if (style == Typeface.ITALIC) {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/HelveticaNeueItalic.ttf")/*
* ,
* -
* 1
*/);
} else if (style == Typeface.BOLD) {
super.setTypeface(Typeface.createFromAsset(getContext().getAssets(), "fonts/HelveticaNeueBold.ttf")/*
* ,
* -
* 1
*/);
}
}
}
and add it in ur xml like this
<xxx.xxxx.utils.CustomTextView
android:id="@+id/login_username_tv"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="0.3"
android:text="Email"
android:padding="5dp"
android:textColor="#333333"
android:textSize="12dp"/>