Android:在PagerTitleStrip中更改字体

Mar*_*101 2 android

有人知道怎么做这个吗?PagerTitleStrip类没有.setTypeface方法或类似的任何东西,所以我有点难过.

我发现的另一个回应是: You are probably best served copying the PagerTitleStrip code (in your SDK or available online), refactor your fork into your own package, and modify it to suit.但我不知道如何去做.

任何帮助将非常感激.

jbu*_*s20 7

您不必复制源 - 只是子类.请参阅我的回答:如何更改pagertitlestrip的字体


Dan*_*iel 5

如果是自定义字体,请将其放在资产文件夹中并像这样更改.

    PagerTitleStrip _Title = (PagerTitleStrip)rootView.findViewById(R.id.__Weekly_pager_title_strip);
    Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "Your font.ttf"); 
    for (int counter = 0 ; counter<_Title.getChildCount(); counter++) {

        if (_Title.getChildAt(counter) instanceof TextView) {
            ((TextView)_Title.getChildAt(counter)).setTypeface(font);
            ((TextView)_Title.getChildAt(counter)).setTextSize(25);
        }

    }
Run Code Online (Sandbox Code Playgroud)