简体   繁体   中英

how to change font family of Tabhost in android

I want to change font family default to my font family. it's possible? please help me

Thank you.

在此处输入图片说明

Setting font and so on:

for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
                Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/my_bolditalic.ttf");
                final TextView tv = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
                tv.setTypeface(tf);
                tv.setTextColor(Color.GREEN);
                mTabHost.getTabWidget().getChildAt(i).setBackground(getResources().getDrawable(R.drawable.bg_tab_selector));
            }
textView.setTypeface(Typeface.createFromAsset(context.getAssets(), "SomeFont.ttf");

Add font files(.ttf,.ttc,.otf etc ) in assets folder
set Fonts is to do it programatically:

TextView tv= (TextView)findViewById(R.id.custom);
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/heartbre.ttf");
tv.setTypeface(face);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM