直播系统平台搭建,管理下划线颜色、高度设置标题是否居中
作者:互联网
直播系统平台搭建,管理下划线颜色、高度设置标题是否居中实现的相关代码
// 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);
}
以上就是直播系统平台搭建,管理下划线颜色、高度设置标题是否居中实现的相关代码, 更多内容欢迎关注之后的文章
标签:居中,下划线,color,getColor,colorTransitionPagerTitleView,直播,Override,public,getResour 来源: https://www.cnblogs.com/yunbaomengnan/p/15438666.html