Search in sources :

Example 1 with CustomTabEntity

use of com.flyco.tablayout.listener.CustomTabEntity in project FlycoTabLayout by H07000223.

the class CommonTabLayout method updateTabStyles.

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View tabView = mTabsContainer.getChildAt(i);
        tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
        TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        tv_tab_title.setTextColor(i == mCurrentTab ? mTextSelectColor : mTextUnselectColor);
        tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
        //            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
        if (mTextAllCaps) {
            tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
        }
        if (mTextBold == TEXT_BOLD_BOTH) {
            tv_tab_title.getPaint().setFakeBoldText(true);
        } else if (mTextBold == TEXT_BOLD_NONE) {
            tv_tab_title.getPaint().setFakeBoldText(false);
        }
        ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
        if (mIconVisible) {
            iv_tab_icon.setVisibility(View.VISIBLE);
            CustomTabEntity tabEntity = mTabEntitys.get(i);
            iv_tab_icon.setImageResource(i == mCurrentTab ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth, mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
            if (mIconGravity == Gravity.LEFT) {
                lp.rightMargin = (int) mIconMargin;
            } else if (mIconGravity == Gravity.RIGHT) {
                lp.leftMargin = (int) mIconMargin;
            } else if (mIconGravity == Gravity.BOTTOM) {
                lp.topMargin = (int) mIconMargin;
            } else {
                lp.bottomMargin = (int) mIconMargin;
            }
            iv_tab_icon.setLayoutParams(lp);
        } else {
            iv_tab_icon.setVisibility(View.GONE);
        }
    }
}
Also used : CustomTabEntity(com.flyco.tablayout.listener.CustomTabEntity) TextView(android.widget.TextView) ImageView(android.widget.ImageView) MsgView(com.flyco.tablayout.widget.MsgView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint) LinearLayout(android.widget.LinearLayout)

Example 2 with CustomTabEntity

use of com.flyco.tablayout.listener.CustomTabEntity in project FlycoTabLayout by H07000223.

the class CommonTabLayout method updateTabSelection.

private void updateTabSelection(int position) {
    for (int i = 0; i < mTabCount; ++i) {
        View tabView = mTabsContainer.getChildAt(i);
        final boolean isSelect = i == position;
        TextView tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        tab_title.setTextColor(isSelect ? mTextSelectColor : mTextUnselectColor);
        ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
        CustomTabEntity tabEntity = mTabEntitys.get(i);
        iv_tab_icon.setImageResource(isSelect ? tabEntity.getTabSelectedIcon() : tabEntity.getTabUnselectedIcon());
        if (mTextBold == TEXT_BOLD_WHEN_SELECT) {
            tab_title.getPaint().setFakeBoldText(isSelect);
        }
    }
}
Also used : CustomTabEntity(com.flyco.tablayout.listener.CustomTabEntity) TextView(android.widget.TextView) ImageView(android.widget.ImageView) MsgView(com.flyco.tablayout.widget.MsgView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint)

Aggregations

Paint (android.graphics.Paint)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 CustomTabEntity (com.flyco.tablayout.listener.CustomTabEntity)2 MsgView (com.flyco.tablayout.widget.MsgView)2 LinearLayout (android.widget.LinearLayout)1