hackware1993 / MagicIndicator

A powerful, customizable and extensible ViewPager indicator framework. As the best alternative of ViewPagerIndicator, TabLayout and PagerSlidingTabStrip —— 强大、可定制、易扩展的 ViewPager 指示器框架。是ViewPagerIndicator、TabLayout、PagerSlidingTabStrip的最佳替代品。支持角标,更支持在非ViewPager场景下使用(使用hide()、show()切换Fragment或使用setVisibility切换FrameLayout里的View等),http://www.jianshu.com/p/f3022211821c
9.68k stars 1.54k forks source link

如何设置选中的文字变粗体?并且大小变大? #206

Open qianshengta opened 4 years ago

qianshengta commented 4 years ago

如何设置选中的文字变粗体?现在我只发现可以改变颜色的方法,好像无法改变文字大小和字体,比如说变成粗体之类的

Joslyn-Chen commented 4 years ago

加粗:getPaint().setFakeBoldText(true);也可以参考demo里的ScaleTransitionPagerTitleView。

qianshengta commented 4 years ago

getPaint()是讲全部的文字设置了粗体 而我的需求是将选中的文字设为粗体,所以我觉得第一个方法行不通,我再看看第二种方法

isuudev commented 4 years ago
@Override
public void onSelected(int index, int totalCount) {
    setTextColor(mSelectedColor);
    getPaint().setFakeBoldText(true);
}

@Override
public void onDeselected(int index, int totalCount) {
    setTextColor(mNormalColor);
    getPaint().setFakeBoldText(false);
}