直播系統平臺搭建,管理下劃線顏色、高度設定標題是否居中

zhibo系統開發發表於2021-10-22

直播系統平臺搭建,管理下劃線顏色、高度設定標題是否居中實現的相關程式碼

//        commonNavigator.setAdjustMode(true);是否設定居中,居中之後,titles很長,就無法展開了
 
 
    private void initIndicator() {
        String[] titles = getResources().getStringArray(R.array.url_titles);
        CommonNavigator commonNavigator = new CommonNavigator(mContext);
        commonNavigator.setAdjustMode(true);
        CommonNavigatorAdapter commonNavigatorAdapter = new CommonNavigatorAdapter() {
 
            @Override
            public int getCount() {
                return titles.length;
            }
 
            @Override
            public IPagerTitleView getTitleView(Context context, final int index) {
 
                ColorTransitionPagerImageTitleView colorTransitionPagerTitleView = new ColorTransitionPagerImageTitleView(context);
 
 
                colorTransitionPagerTitleView.setNormalColor(getResources().getColor(R.color.color_grey_text8));
                colorTransitionPagerTitleView.setSelectedColor(getResources().getColor(R.color.blue_1));
                colorTransitionPagerTitleView.setText(titles[index]);
 
                colorTransitionPagerTitleView.getPaint().setFakeBoldText(true);
 
 
                colorTransitionPagerTitleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (index != viewPager.getCurrentItem()) {
                            viewPager.setCurrentItem(index, false);
                        }
                    }
                });
                return colorTransitionPagerTitleView;
            }
 
            @Override
            public IPagerIndicator getIndicator(Context context) {
 
                LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
                linePagerIndicator.setMode(LinePagerIndicator.MODE_MATCH_EDGE);
//高度            
    linePagerIndicator.setLineHeight(2);
 
//顏色                
linePagerIndicator.setColors(getResources().getColor(R.color.blue_1));
                return linePagerIndicator;
            }
 
        };
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
 
            }
 
            @Override
            public void onPageSelected(int position) {
//                StatusBarUtil.transparencyBar(mActivity);
//                DLog.d(TAG, "StatusBarUtil: type=" + type);
//                if (position == 2) {
//                    setBannerColor(mContext.getResources().getColor(R.color.me_banner_color));
//                    setNavigationBarColor(mContext.getResources().getColor(R.color.white));
//                } else {
//                    StatusBarUtil.StatusBarLightMode(mActivity, type);
//                    setBannerColor(mContext.getResources().getColor(R.color.main_banner_bg_color));
//                    setNavigationBarColor(mContext.getResources().getColor(R.color.white));
//                }
            }
 
            @Override
            public void onPageScrollStateChanged(int state) {
 
            }
        });
        commonNavigator.setAdapter(commonNavigatorAdapter);
        indicator.setNavigator(commonNavigator);
        ViewPagerHelper.bind(indicator, viewPager);
    }

以上就是直播系統平臺搭建,管理下劃線顏色、高度設定標題是否居中實現的相關程式碼, 更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2838773/,如需轉載,請註明出處,否則將追究法律責任。

相關文章