MaterialBadgeTextView.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:JLibraryDemo 作者:
/**
 *
 * @param isDisplayInToolbarMenu
 */
public void setHighLightMode(boolean isDisplayInToolbarMenu){
    isHighLightMode = true;
    ViewGroup.LayoutParams params = getLayoutParams();
    params.width = dp2px(getContext(), 8);
    params.height = params.width;
    if(isDisplayInToolbarMenu && params instanceof FrameLayout.LayoutParams){
        ((FrameLayout.LayoutParams)params).topMargin=dp2px(getContext(), 8);
        ((FrameLayout.LayoutParams)params).rightMargin=dp2px(getContext(), 8);
    }
    setLayoutParams(params);
    ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, drawable.getPaint());
    drawable.getPaint().setColor(backgroundColor);
    drawable.getPaint().setAntiAlias(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(drawable);
    } else {
        setBackgroundDrawable(drawable);
    }
    setText("");
    setVisibility(View.VISIBLE);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号