Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Typeface droidSerifMonoTF = Typeface.createFromAsset(getAssets(), "fonts/DroidSerif.ttf");
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- TextView t = new TextView(this);
- t.setText(mSectionsPagerAdapter.getPageTitle(i) );
- t.setTypeface(droidSansMonoTF);
- actionBar.addTab(actionBar.newTab()
- .setCustomView(t)
- .setTabListener(this));
- }
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom){
- super.onLayout(changed, left, top, right, bottom);
- final ViewGroup tabStrip = (ViewGroup)getChildAt(0);
- final int tabCount = tabStrip.getChildCount();
- ViewGroup tabView;
- int tabChildCount;
- View tabViewChild;
- for(int i=0; i<tabCount; i++){
- tabView = (ViewGroup)tabStrip.getChildAt(i);
- tabChildCount = tabView.getChildCount();
- for(int j=0; j<tabChildCount; j++){
- tabViewChild = tabView.getChildAt(j);
- if(tabViewChild instanceof AppCompatTextView){
- if(fontFace == null){
- fontFace = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.IranSans));
- }
- ((TextView) tabViewChild).setTypeface(fontFace, Typeface.BOLD);
- }
- }
- }
- }
- if(fontFace == null){
- fontFace = Typeface.createFromAsset(context.getAssets(), context.getString(R.string.IranSans));
- }
- <style name="tabLayoutTitles">
- <item name="android:textColor">@color/white</item>
- <item name="android:textSize">@dimen/appFirstFontSize</item>
- <item name="android:fontFamily">@font/vazir_bold</item>
- </style>
- <style name="defaultTabLayout">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">@dimen/defaultTabLayoutHeight</item>
- <item name="android:gravity">right</item>
- <item name="tabTextAppearance">@style/tabLayoutTitles</item>
- <item name="tabSelectedTextColor">@color/white</item>
- <item name="tabIndicatorColor">@color/white</item>
- <item name="tabIndicatorHeight">@dimen/accomTabIndicatorHeight</item>
- <item name="tabMode">fixed</item>
- <item name="tabGravity">fill</item>
- <item name="tabBackground">@drawable/rectangle_white_ripple</item>
- <item name="android:background">@color/colorPrimary</item>
- </style>
Add Comment
Please, Sign In to add comment