H07000223 / FlycoTabLayout

An Android TabLayout Lib
MIT License
11.06k stars 2.42k forks source link

完美解决选中后字体选中后字体大小问题! #525

Open yecaler opened 3 years ago

yecaler commented 3 years ago

1.设置viewpager的选中事件监听。 viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            setTextSize(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    setTextSize(tablayout.getCurrentTab());

2.设置选中后的字体大小 private void setTextSize(int position) { for (int i = 0; i < mAdapter.getCount(); i++) { TextView textView = tablayout.getTitleView(i); if (position == i) { textView.setTextSize(18); } else { textView.setTextSize(16); } } } 完成。

junixapp commented 3 years ago

https://github.com/li-xiaojun/FlycoTabLayout 增强版,androidx, 支持设置选中字体大小和自定义字体

BestCyrus commented 2 years ago

我一直都是把作者库源码考过去自己改的