Search in sources :

Example 1 with MsgView

use of com.flyco.tablayout.widget.MsgView in project Android-skin-support by ximsfei.

the class SlidingTabActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sliding_tab);
    for (String title : mTitles) {
        mFragments.add(SimpleCardFragment.getInstance(title));
    }
    View decorView = getWindow().getDecorView();
    ViewPager vp = ViewFindUtils.find(decorView, R.id.vp);
    mAdapter = new MyPagerAdapter(getSupportFragmentManager());
    vp.setAdapter(mAdapter);
    /** 默认 */
    SlidingTabLayout tabLayout_1 = ViewFindUtils.find(decorView, R.id.tl_1);
    /**自定义部分属性*/
    SlidingTabLayout tabLayout_2 = ViewFindUtils.find(decorView, R.id.tl_2);
    /** 字体加粗,大写 */
    SlidingTabLayout tabLayout_3 = ViewFindUtils.find(decorView, R.id.tl_3);
    /** tab固定宽度 */
    SlidingTabLayout tabLayout_4 = ViewFindUtils.find(decorView, R.id.tl_4);
    /** indicator固定宽度 */
    SlidingTabLayout tabLayout_5 = ViewFindUtils.find(decorView, R.id.tl_5);
    /** indicator圆 */
    SlidingTabLayout tabLayout_6 = ViewFindUtils.find(decorView, R.id.tl_6);
    /** indicator矩形圆角 */
    final SlidingTabLayout tabLayout_7 = ViewFindUtils.find(decorView, R.id.tl_7);
    /** indicator三角形 */
    SlidingTabLayout tabLayout_8 = ViewFindUtils.find(decorView, R.id.tl_8);
    /** indicator圆角色块 */
    SlidingTabLayout tabLayout_9 = ViewFindUtils.find(decorView, R.id.tl_9);
    /** indicator圆角色块 */
    SlidingTabLayout tabLayout_10 = ViewFindUtils.find(decorView, R.id.tl_10);
    tabLayout_1.setViewPager(vp);
    tabLayout_2.setViewPager(vp);
    tabLayout_2.setOnTabSelectListener(this);
    tabLayout_3.setViewPager(vp);
    tabLayout_4.setViewPager(vp);
    tabLayout_5.setViewPager(vp);
    tabLayout_6.setViewPager(vp);
    tabLayout_7.setViewPager(vp, mTitles);
    tabLayout_8.setViewPager(vp, mTitles, this, mFragments);
    tabLayout_9.setViewPager(vp);
    tabLayout_10.setViewPager(vp);
    vp.setCurrentItem(4);
    tabLayout_1.showDot(4);
    MsgView rtv_1_4 = tabLayout_1.getMsgView(4);
    if (rtv_1_4 != null) {
        if (rtv_1_4 instanceof SkinMsgView) {
            ((SkinMsgView) rtv_1_4).setBackgroundColorResource(R.color.msg_background_color);
            ((SkinMsgView) rtv_1_4).setStrokeColorResource(R.color.msg_stroke_color);
        } else {
            rtv_1_4.setBackgroundColor(Color.parseColor("#6D8FB0"));
        }
    }
    tabLayout_3.showDot(4);
    tabLayout_2.showDot(4);
    tabLayout_2.showMsg(3, 5);
    tabLayout_2.setMsgMargin(3, 0, 10);
    MsgView rtv_2_3 = tabLayout_2.getMsgView(3);
    if (rtv_2_3 != null) {
        if (rtv_2_3 instanceof SkinMsgView) {
            ((SkinMsgView) rtv_2_3).setBackgroundColorResource(R.color.msg_background_color);
            ((SkinMsgView) rtv_2_3).setStrokeColorResource(R.color.msg_stroke_color);
        } else {
            rtv_2_3.setBackgroundColor(Color.parseColor("#6D8FB0"));
        }
    }
    tabLayout_2.showMsg(5, 5);
    tabLayout_2.setMsgMargin(5, 0, 10);
//        tabLayout_7.setOnTabSelectListener(new OnTabSelectListener() {
//            @Override
//            public void onTabSelect(int position) {
//                Toast.makeText(mContext, "onTabSelect&position--->" + position, Toast.LENGTH_SHORT).show();
//            }
//
//            @Override
//            public void onTabReselect(int position) {
//                mFragments.add(SimpleCardFragment.getInstance("后端"));
//                mAdapter.notifyDataSetChanged();
//                tabLayout_7.addNewTab("后端");
//            }
//        });
}
Also used : SkinMsgView(skin.support.flycotablayout.widget.SkinMsgView) SkinMsgView(skin.support.flycotablayout.widget.SkinMsgView) MsgView(com.flyco.tablayout.widget.MsgView) SlidingTabLayout(com.flyco.tablayout.SlidingTabLayout) SkinMsgView(skin.support.flycotablayout.widget.SkinMsgView) MsgView(com.flyco.tablayout.widget.MsgView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Example 2 with MsgView

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

the class CommonTabActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_common_tab);
    for (String title : mTitles) {
        mFragments.add(SimpleCardFragment.getInstance("Switch ViewPager " + title));
        mFragments2.add(SimpleCardFragment.getInstance("Switch Fragment " + title));
    }
    for (int i = 0; i < mTitles.length; i++) {
        mTabEntities.add(new TabEntity(mTitles[i], mIconSelectIds[i], mIconUnselectIds[i]));
    }
    mDecorView = getWindow().getDecorView();
    mViewPager = ViewFindUtils.find(mDecorView, R.id.vp_2);
    mViewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
    /** with nothing */
    mTabLayout_1 = ViewFindUtils.find(mDecorView, R.id.tl_1);
    /** with ViewPager */
    mTabLayout_2 = ViewFindUtils.find(mDecorView, R.id.tl_2);
    /** with Fragments */
    mTabLayout_3 = ViewFindUtils.find(mDecorView, R.id.tl_3);
    /** indicator固定宽度 */
    mTabLayout_4 = ViewFindUtils.find(mDecorView, R.id.tl_4);
    /** indicator固定宽度 */
    mTabLayout_5 = ViewFindUtils.find(mDecorView, R.id.tl_5);
    /** indicator矩形圆角 */
    mTabLayout_6 = ViewFindUtils.find(mDecorView, R.id.tl_6);
    /** indicator三角形 */
    mTabLayout_7 = ViewFindUtils.find(mDecorView, R.id.tl_7);
    /** indicator圆角色块 */
    mTabLayout_8 = ViewFindUtils.find(mDecorView, R.id.tl_8);
    mTabLayout_1.setTabData(mTabEntities);
    tl_2();
    mTabLayout_3.setTabData(mTabEntities, this, R.id.fl_change, mFragments2);
    mTabLayout_4.setTabData(mTabEntities);
    mTabLayout_5.setTabData(mTabEntities);
    mTabLayout_6.setTabData(mTabEntities);
    mTabLayout_7.setTabData(mTabEntities);
    mTabLayout_8.setTabData(mTabEntities);
    mTabLayout_3.setOnTabSelectListener(new OnTabSelectListener() {

        @Override
        public void onTabSelect(int position) {
            mTabLayout_1.setCurrentTab(position);
            mTabLayout_2.setCurrentTab(position);
            mTabLayout_4.setCurrentTab(position);
            mTabLayout_5.setCurrentTab(position);
            mTabLayout_6.setCurrentTab(position);
            mTabLayout_7.setCurrentTab(position);
            mTabLayout_8.setCurrentTab(position);
        }

        @Override
        public void onTabReselect(int position) {
        }
    });
    mTabLayout_8.setCurrentTab(2);
    mTabLayout_3.setCurrentTab(1);
    //显示未读红点
    mTabLayout_1.showDot(2);
    mTabLayout_3.showDot(1);
    mTabLayout_4.showDot(1);
    //两位数
    mTabLayout_2.showMsg(0, 55);
    mTabLayout_2.setMsgMargin(0, -5, 5);
    //三位数
    mTabLayout_2.showMsg(1, 100);
    mTabLayout_2.setMsgMargin(1, -5, 5);
    //设置未读消息红点
    mTabLayout_2.showDot(2);
    MsgView rtv_2_2 = mTabLayout_2.getMsgView(2);
    if (rtv_2_2 != null) {
        UnreadMsgUtils.setSize(rtv_2_2, dp2px(7.5f));
    }
    //设置未读消息背景
    mTabLayout_2.showMsg(3, 5);
    mTabLayout_2.setMsgMargin(3, 0, 5);
    MsgView rtv_2_3 = mTabLayout_2.getMsgView(3);
    if (rtv_2_3 != null) {
        rtv_2_3.setBackgroundColor(Color.parseColor("#6D8FB0"));
    }
}
Also used : TabEntity(com.flyco.tablayoutsamples.entity.TabEntity) CustomTabEntity(com.flyco.tablayout.listener.CustomTabEntity) MsgView(com.flyco.tablayout.widget.MsgView) OnTabSelectListener(com.flyco.tablayout.listener.OnTabSelectListener)

Example 3 with MsgView

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

the class CommonTabLayout 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;
        }
        if (!mIconVisible) {
            setMsgMargin(position, 2, 2);
        } else {
            setMsgMargin(position, 0, mIconGravity == Gravity.LEFT || mIconGravity == Gravity.RIGHT ? 4 : 0);
        }
        mInitSetMap.put(position, true);
    }
}
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 4 with MsgView

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

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

Example 5 with MsgView

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

the class SegmentTabLayout 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) 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