package com.example;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyTextViewTitle extends TextView {
Typeface mTypeface;
public MyTextViewTitle(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MyTextViewTitle(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyTextViewTitle(Context context) {
super(context);
init();
}
private void init() {
if (!isInEditMode()) {
mTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/Rupee_Foradian.ttf");
setTypeface(mTypeface,Typeface.BOLD);
}
}
}
And In XML File
<com.example.MyTextViewTitle
android:id="@+id/titel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My text"
android:textSize="22sp"
/>
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class MyTextViewTitle extends TextView {
Typeface mTypeface;
public MyTextViewTitle(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MyTextViewTitle(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyTextViewTitle(Context context) {
super(context);
init();
}
private void init() {
if (!isInEditMode()) {
mTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/Rupee_Foradian.ttf");
setTypeface(mTypeface,Typeface.BOLD);
}
}
}
And In XML File
<com.example.MyTextViewTitle
android:id="@+id/titel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My text"
android:textSize="22sp"
/>
No comments:
Post a Comment