zoukankan      html  css  js  c++  java
  • PagerSlidingTabStrip 高亮选中标题

    1、选中标题后,高亮标题
    @Override
    public void onPageSelected(int position) { setSelectTextColor(position); if (delegatePageListener != null) { delegatePageListener.onPageSelected(position); } }
    private void setSelectTextColor(int position) {
            for (int i = 0; i < tabCount; i++) {
                View view = tabsContainer.getChildAt(i);
                if (view instanceof ImageButton) {
                } else if (view instanceof RelativeLayout) {
                    View viewText = ((RelativeLayout) view).getChildAt(0);
                    TextView tabTextView = (TextView) viewText;
                    if (viewText instanceof TextView) {
                        if (position == i) {
                            tabTextView.setTextColor(自定义颜色);
                        } else {
                            tabTextView.setTextColor(tabTextColor);
                        }
                    }
                }
            }
        }

    2、首次进入默认第一个标题高亮,关键标红代码

        private void updateTabStyles() {
    
            for (int i = 0; i < tabCount; i++) {
    
                View v = tabsContainer.getChildAt(i);
    
                v.setBackgroundResource(tabBackgroundResId);
    
                if (v instanceof RelativeLayout) {
                    View v1 = ((RelativeLayout) v).getChildAt(0);
                    if (v1 instanceof TextView) {
    
                        TextView tab = (TextView) v1;
                        tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
                        tab.setTypeface(tabTypeface, tabTypefaceStyle);
                        if (i == 0) {
                            tab.setTextColor(自定义颜色);
                        } else {
                            tab.setTextColor(tabTextColor);
                        }
    
                        if (textAllCaps) {
                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                                tab.setAllCaps(true);
                            } else {
                                tab.setText(tab.getText().toString().toUpperCase(locale));
                            }
                        }
                    }
                }
            }
        }
  • 相关阅读:
    ora-01034 ora-27101解决方法(亲测)
    windows C++内存检测
    oracle求特定字符的个数
    ORACLE查看并修改最大连接数
    你必须用角色管理工具安装Microsoft .NET Framework 3.5
    让VC编译的Release版本程序在其他机器上顺利运行
    创建数据库连接
    C++ 判断进程是否存在
    excel
    毕设学习笔记
  • 原文地址:https://www.cnblogs.com/zgz345/p/3834138.html
Copyright © 2011-2022 走看看