Search in sources :

Example 11 with MsgView

use of com.flyco.tablayout.widget.MsgView in project FlycoTabLayout by H07000223.

the class CommonTabLayout method setMsgMargin.

/**
     * 设置提示红点偏移,注意
     * 1.控件为固定高度:参照点为tab内容的右上角
     * 2.控件高度不固定(WRAP_CONTENT):参照点为tab内容的右上角,此时高度已是红点的最高显示范围,所以这时bottomPadding其实就是topPadding
     */
public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    if (tipView != null) {
        TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
        mTextPaint.setTextSize(mTextsize);
        float textWidth = mTextPaint.measureText(tv_tab_title.getText().toString());
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        MarginLayoutParams lp = (MarginLayoutParams) tipView.getLayoutParams();
        float iconH = mIconHeight;
        float margin = 0;
        if (mIconVisible) {
            if (iconH <= 0) {
                iconH = mContext.getResources().getDrawable(mTabEntitys.get(position).getTabSelectedIcon()).getIntrinsicHeight();
            }
            margin = mIconMargin;
        }
        if (mIconGravity == Gravity.TOP || mIconGravity == Gravity.BOTTOM) {
            lp.leftMargin = dp2px(leftPadding);
            lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight - iconH - margin) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
        } else {
            lp.leftMargin = dp2px(leftPadding);
            lp.topMargin = mHeight > 0 ? (int) (mHeight - Math.max(textHeight, iconH)) / 2 - dp2px(bottomPadding) : dp2px(bottomPadding);
        }
        tipView.setLayoutParams(lp);
    }
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) TextView(android.widget.TextView) MsgView(com.flyco.tablayout.widget.MsgView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 12 with MsgView

use of com.flyco.tablayout.widget.MsgView in project FlycoTabLayout by H07000223.

the class CommonTabLayout method getMsgView.

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */
public MsgView getMsgView(int position) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    return tipView;
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) MsgView(com.flyco.tablayout.widget.MsgView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 13 with MsgView

use of com.flyco.tablayout.widget.MsgView in project FlycoTabLayout by H07000223.

the class SlidingTabLayout method hideMsg.

/** 隐藏未读消息 */
public void hideMsg(int position) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    if (tipView != null) {
        tipView.setVisibility(View.GONE);
    }
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) MsgView(com.flyco.tablayout.widget.MsgView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView)

Example 14 with MsgView

use of com.flyco.tablayout.widget.MsgView in project FlycoTabLayout by H07000223.

the class SlidingTabLayout method getMsgView.

/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取MsgView对象从而各种设置 */
public MsgView getMsgView(int position) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    return tipView;
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) MsgView(com.flyco.tablayout.widget.MsgView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView)

Example 15 with MsgView

use of com.flyco.tablayout.widget.MsgView in project FlycoTabLayout by H07000223.

the class SegmentTabActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_segment_tab);
    for (String title : mTitles_3) {
        mFragments.add(SimpleCardFragment.getInstance("Switch ViewPager " + title));
    }
    for (String title : mTitles_2) {
        mFragments2.add(SimpleCardFragment.getInstance("Switch Fragment " + title));
    }
    mDecorView = getWindow().getDecorView();
    SegmentTabLayout tabLayout_1 = ViewFindUtils.find(mDecorView, R.id.tl_1);
    SegmentTabLayout tabLayout_2 = ViewFindUtils.find(mDecorView, R.id.tl_2);
    mTabLayout_3 = ViewFindUtils.find(mDecorView, R.id.tl_3);
    SegmentTabLayout tabLayout_4 = ViewFindUtils.find(mDecorView, R.id.tl_4);
    SegmentTabLayout tabLayout_5 = ViewFindUtils.find(mDecorView, R.id.tl_5);
    tabLayout_1.setTabData(mTitles);
    tabLayout_2.setTabData(mTitles_2);
    tl_3();
    tabLayout_4.setTabData(mTitles_2, this, R.id.fl_change, mFragments2);
    tabLayout_5.setTabData(mTitles_3);
    //显示未读红点
    tabLayout_1.showDot(2);
    tabLayout_2.showDot(2);
    mTabLayout_3.showDot(1);
    tabLayout_4.showDot(1);
    //设置未读消息红点
    mTabLayout_3.showDot(2);
    MsgView rtv_3_2 = mTabLayout_3.getMsgView(2);
    if (rtv_3_2 != null) {
        rtv_3_2.setBackgroundColor(Color.parseColor("#6D8FB0"));
    }
}
Also used : SegmentTabLayout(com.flyco.tablayout.SegmentTabLayout) MsgView(com.flyco.tablayout.widget.MsgView)

Aggregations

MsgView (com.flyco.tablayout.widget.MsgView)18 View (android.view.View)14 TextView (android.widget.TextView)12 HorizontalScrollView (android.widget.HorizontalScrollView)4 ImageView (android.widget.ImageView)4 SkinMsgView (skin.support.flycotablayout.widget.SkinMsgView)3 ViewPager (android.support.v4.view.ViewPager)2 SegmentTabLayout (com.flyco.tablayout.SegmentTabLayout)2 SlidingTabLayout (com.flyco.tablayout.SlidingTabLayout)2 CustomTabEntity (com.flyco.tablayout.listener.CustomTabEntity)2 OnTabSelectListener (com.flyco.tablayout.listener.OnTabSelectListener)2 TabEntity (com.flyco.tablayoutsamples.entity.TabEntity)1 TabEntity (com.ximsfei.skindemo.flycotablayout.entity.TabEntity)1