If you want to create custom auto textview components you have to extends widget class like TextView,Button etc.Its very simple create your own class and write constructor corresponding to the constructor of the base class.
CustomFont class
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
public class CustomFont extends TextView{
Context context;
String ttfName="";
String TAG = getClass().getName();
public CustomFont(Context context, AttributeSet attrs)
{
super(context, attrs);
this.context = context;
init();
}
private void init() {
Typeface font = Typeface.createFromAsset(context.getAssets(), "lucon.ttf");
setTypeface(font);
}
@Override
public void setTypeface(Typeface tf) {
super.setTypeface(tf);
}
}
crate xml file and replace your with following code :
<packagename.classname
android:id="@+id/customfont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textColor="@color/text_color"
android:textSize="@dimen/text_size;
0 Comment(s)