Skip to content

Instantly share code, notes, and snippets.

@gokhanaliccii
Last active August 29, 2015 14:25
Show Gist options
  • Save gokhanaliccii/0efa082069db36f54ab2 to your computer and use it in GitHub Desktop.
Save gokhanaliccii/0efa082069db36f54ab2 to your computer and use it in GitHub Desktop.
package view;
import utility.FontHelper;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
import com.menulux.pos.R;
import enums.Font;
public class CustomFontTextView extends TextView {
/**
* Constructor CustomFontTextView()
*/
public CustomFontTextView(Context context) {
super(context);
}
/**
* Constructor CustomFontTextView()
*/
public CustomFontTextView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomFontTextView);
int defaultFont = context.getResources().getInteger(R.integer.default_font);
int fontValue = typedArray.getInt(R.styleable.CustomFontTextView_font, defaultFont);
Font font = Font.getFont(fontValue);
Typeface typeface = FontHelper.getInstance().getFont(context, font);
setTypeface(typeface);
typedArray.recycle();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment