Guest User

Untitled

a guest
Oct 15th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <item name="fontFamily">@font/avalon</item>
  2.  
  3. public class MyTextView extends TextView {
  4.  
  5. public MyTextView(Context context, AttributeSet attrs, int defStyle) {
  6. super(context, attrs, defStyle);
  7. init();
  8. }
  9.  
  10. public MyTextView(Context context, AttributeSet attrs) {
  11. super(context, attrs);
  12. init();
  13. }
  14.  
  15. public MyTextView(Context context) {
  16. super(context);
  17. init();
  18. }
  19.  
  20. private void init() {
  21. if (!isInEditMode()) {
  22. Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "fonts/custom.ttf");
  23. setTypeface(tf);
  24. }
  25. }
  26.  
  27. Typeface typeface=Typeface.createFromAsset(getAssets(), "fonts/custom.ttf");
  28. myTextView.setTypeface(typeface);
Add Comment
Please, Sign In to add comment