Search in sources :

Example 6 with MsgView

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

the class SegmentTabLayout method showMsg.

/**
     * 显示未读消息
     *
     * @param position 显示tab位置
     * @param num      num小于等于0显示红点,num大于0显示数字
     */
public void showMsg(int position, int num) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    if (tipView != null) {
        UnreadMsgUtils.show(tipView, num);
        if (mInitSetMap.get(position) != null && mInitSetMap.get(position)) {
            return;
        }
        setMsgMargin(position, 2, 2);
        mInitSetMap.put(position, true);
    }
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) MsgView(com.flyco.tablayout.widget.MsgView) View(android.view.View) TextView(android.widget.TextView)

Example 7 with MsgView

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

the class SegmentTabLayout 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) View(android.view.View) TextView(android.widget.TextView)

Example 8 with MsgView

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

the class SegmentTabLayout 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();
        lp.leftMargin = dp2px(leftPadding);
        lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight) / 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) View(android.view.View) TextView(android.widget.TextView)

Example 9 with MsgView

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

the class SlidingTabLayout method setMsgMargin.

/** 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 */
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();
        lp.leftMargin = mTabWidth >= 0 ? (int) (mTabWidth / 2 + textWidth / 2 + dp2px(leftPadding)) : (int) (mTabPadding + textWidth + dp2px(leftPadding));
        lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight) / 2 - dp2px(bottomPadding) : 0;
        tipView.setLayoutParams(lp);
    }
}
Also used : MsgView(com.flyco.tablayout.widget.MsgView) TextView(android.widget.TextView) MsgView(com.flyco.tablayout.widget.MsgView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView)

Example 10 with MsgView

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

the class SlidingTabLayout method showMsg.

/**
     * 显示未读消息
     *
     * @param position 显示tab位置
     * @param num      num小于等于0显示红点,num大于0显示数字
     */
public void showMsg(int position, int num) {
    if (position >= mTabCount) {
        position = mTabCount - 1;
    }
    View tabView = mTabsContainer.getChildAt(position);
    MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
    if (tipView != null) {
        UnreadMsgUtils.show(tipView, num);
        if (mInitSetMap.get(position) != null && mInitSetMap.get(position)) {
            return;
        }
        setMsgMargin(position, 4, 2);
        mInitSetMap.put(position, true);
    }
}
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)

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