Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何设置TitleView的背景色,直接设置后,指示器的颜色会被遮住 #296

Open
liquor2020 opened this issue Sep 28, 2023 · 0 comments

Comments

@liquor2020
Copy link

commonNavigator.setAdapter(new CommonNavigatorAdapter() {
         
       @Override
        public int getCount() {
            return null == titleList ? 0 : titleList.size();
        }

        @Override
        public IPagerTitleView getTitleView(Context context, final int index) {
            SimplePagerTitleView titleView = new SimplePagerTitleView(context);
            titleView.setText(titleList.get(index));
            titleView.setTextSize(14);
            titleView.setNormalColor(ContextCompat.getColor(GenerateResultActivity.this, R.color._666666));
            titleView.setSelectedColor(ContextCompat.getColor(GenerateResultActivity.this, R.color.white));
            // 设置背景色
            titleView.setBackground(ContextCompat.getDrawable(GenerateResultActivity.this, R.drawable.bg_generate));
            titleView.setOnClickListener(v -> mBinding.viewPager.setCurrentItem(index));
            return titleView;
        }

        @Override
        public IPagerIndicator getIndicator(Context context) {
            LinePagerIndicator indicator = new LinePagerIndicator(context);
            indicator.setLineHeight(ConvertUtils.dp2px(34));
            indicator.setRoundRadius(ConvertUtils.dp2px(8));
            indicator.setColors(ContextCompat.getColor(GenerateResultActivity.this, R.color._F95A23));
            return indicator;
        }
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant