• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MsgView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.flyco.tablayout.widget.MsgView的典型用法代码示例。如果您正苦于以下问题:Java MsgView类的具体用法?Java MsgView怎么用?Java MsgView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MsgView类属于com.flyco.tablayout.widget包,在下文中一共展示了MsgView类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: showMsg

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 显示未读消息
 *
 * @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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SegmentTabLayout.java


示例2: setMsgMargin

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 设置提示红点偏移,注意
 * 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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:SegmentTabLayout.java


示例3: showMsg

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 显示未读消息
 *
 * @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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:SlidingTabLayout.java


示例4: setMsgMargin

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/** 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 */
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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SlidingTabLayout.java


示例5: showMsg

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 显示未读消息
 *
 * @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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:CommonTabLayout.java


示例6: setMsgMargin

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳
 */
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);
    }
}
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:21,代码来源:SlidingTabLayout.java


示例7: getMsgView

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/** 当前类只提供了少许设置未读消息属性的方法,可以通过该方法获取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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:SegmentTabLayout.java


示例8: hideMsg

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:CommonTabLayout.java


示例9: setMsgMargin

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
/**
 * 设置提示红点偏移,注意
 * 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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:CommonTabLayout.java


示例10: show

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
public static void show(MsgView msgView, int num) {
    if (msgView == null) {
        return;
    }
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) msgView.getLayoutParams();
    DisplayMetrics dm = msgView.getResources().getDisplayMetrics();
    msgView.setVisibility(View.VISIBLE);
    if (num <= 0) {//圆点,设置默认宽高
        msgView.setStrokeWidth(0);
        msgView.setText("");

        lp.width = (int) (5 * dm.density);
        lp.height = (int) (5 * dm.density);
        msgView.setLayoutParams(lp);
    } else {
        lp.height = (int) (18 * dm.density);
        if (num > 0 && num < 10) {//圆
            lp.width = (int) (18 * dm.density);
            msgView.setText(num + "");
        } else if (num > 9 && num < 100) {//圆角矩形,圆角是高度的一半,设置默认padding
            lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
            msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
            msgView.setText(num + "");
        } else {//数字超过两位,显示99+
            lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
            msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
            msgView.setText("99+");
        }
        msgView.setLayoutParams(lp);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:UnreadMsgUtils.java


示例11: setSize

import com.flyco.tablayout.widget.MsgView; //导入依赖的package包/类
public static void setSize(MsgView rtv, int size) {
    if (rtv == null) {
        return;
    }
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rtv.getLayoutParams();
    lp.width = size;
    lp.height = size;
    rtv.setLayoutParams(lp);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:UnreadMsgUtils.java



注:本文中的com.flyco.tablayout.widget.MsgView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleSelector类代码示例发布时间:2022-05-22
下一篇:
Java Pipeline类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap