Guest User

Untitled

a guest
Oct 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. Typeface droidSerifMonoTF = Typeface.createFromAsset(getAssets(), "fonts/DroidSerif.ttf");
  2.  
  3. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
  4. TextView t = new TextView(this);
  5. t.setText(mSectionsPagerAdapter.getPageTitle(i) );
  6. t.setTypeface(droidSansMonoTF);
  7.  
  8. actionBar.addTab(actionBar.newTab()
  9. .setCustomView(t)
  10. .setTabListener(this));
  11.  
  12. }
  13.  
  14. @Override
  15. protected void onLayout(boolean changed, int left, int top, int right, int bottom){
  16. super.onLayout(changed, left, top, right, bottom);
  17.  
  18. final ViewGroup tabStrip = (ViewGroup)getChildAt(0);
  19. final int tabCount = tabStrip.getChildCount();
  20. ViewGroup tabView;
  21. int tabChildCount;
  22. View tabViewChild;
  23.  
  24. for(int i=0; i<tabCount; i++){
  25. tabView = (ViewGroup)tabStrip.getChildAt(i);
  26. tabChildCount = tabView.getChildCount();
  27. for(int j=0; j<tabChildCount; j++){
  28. tabViewChild = tabView.getChildAt(j);
  29. if(tabViewChild instanceof AppCompatTextView){
  30. if(fontFace == null){
  31. fontFace = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.IranSans));
  32. }
  33. ((TextView) tabViewChild).setTypeface(fontFace, Typeface.BOLD);
  34. }
  35. }
  36. }
  37. }
  38.  
  39. if(fontFace == null){
  40. fontFace = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.IranSans));
  41. }
  42.  
  43. <style name="tabLayoutTitles">
  44. <item name="android:textColor">@color/white</item>
  45. <item name="android:textSize">@dimen/appFirstFontSize</item>
  46. <item name="android:fontFamily">@font/vazir_bold</item>
  47. </style>
  48.  
  49. <style name="defaultTabLayout">
  50. <item name="android:layout_width">match_parent</item>
  51. <item name="android:layout_height">@dimen/defaultTabLayoutHeight</item>
  52. <item name="android:gravity">right</item>
  53. <item name="tabTextAppearance">@style/tabLayoutTitles</item>
  54. <item name="tabSelectedTextColor">@color/white</item>
  55. <item name="tabIndicatorColor">@color/white</item>
  56. <item name="tabIndicatorHeight">@dimen/accomTabIndicatorHeight</item>
  57. <item name="tabMode">fixed</item>
  58. <item name="tabGravity">fill</item>
  59. <item name="tabBackground">@drawable/rectangle_white_ripple</item>
  60. <item name="android:background">@color/colorPrimary</item>
  61. </style>
Add Comment
Please, Sign In to add comment