Last active
August 29, 2015 14:25
-
-
Save gokhanaliccii/0efa082069db36f54ab2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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