• Android BGABadgeView:显示提示数字(2)


    

    Android BGABadgeView:显示提示数字(2)

    在附录文章3的基础上,对代码进行稍微改造,显示在红色小圆球内部显示数字,同时给红色小圆球通过可编程调控红色小圆球的整体外观,布局文件和附录文章3类似。主要是Java代码:

    package zhangphil.demo;
    
    import android.graphics.Color;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    
    import cn.bingoogolapple.badgeview.BGABadgeTextView;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            final BGABadgeTextView badgeTextView = (BGABadgeTextView) findViewById(R.id.text);
            badgeTextView.showCirclePointBadge();
    
            //初始化
            badgeTextView.showTextBadge("9");
            badgeTextView.getBadgeViewHelper().setBadgeTextSizeSp(15);
            badgeTextView.getBadgeViewHelper().setBadgeTextColorInt(Color.WHITE);
            badgeTextView.getBadgeViewHelper().setBadgeBgColorInt(Color.RED);
            badgeTextView.getBadgeViewHelper().setDragable(true);
            badgeTextView.getBadgeViewHelper().setBadgePaddingDp(6);
            badgeTextView.getBadgeViewHelper().setBadgeBorderWidthDp(2);
            badgeTextView.getBadgeViewHelper().setBadgeBorderColorInt(Color.WHITE);
    
            findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (badgeTextView.isShowBadge())
                        badgeTextView.hiddenBadge();
                    else {
                        badgeTextView.showCirclePointBadge();
    
                        //注意带上这个显示数字,否则将变成空
                        badgeTextView.showTextBadge("99+");
                    }
                }
            });
        }
    }
    


    代码运行结果:



    附录文章:
    1,《仿微信、短信、QQ等消息数目右上角红色小圆球气泡显示(基于Android XML布局文件实现)》链接地址:http://blog.csdn.net/zhangphil/article/details/43702953 
    2,《仿短信条目右上角的红色小圆球提示气泡》链接地址:http://blog.csdn.net/zhangphil/article/details/43667727
    3,《Android BGABadgeView:新消息/未接来电/未读消息/新通知圆球红点提示(1)》链接地址:http://blog.csdn.net/zhangphil/article/details/51822514

  • 相关阅读:
    2012年春晚剧本
    研究机器人
    85.圆角边框的两大要素 Walker
    81.边框设置 Walker
    76.背景固定 Walker
    84.边框方向 Walker
    86.圆角边框设置 Walker
    82.边框宽度和边框颜色 Walker
    88.轮廓和样式重置 Walker
    77.背景简写 Walker
  • 原文地址:https://www.cnblogs.com/hehehaha/p/6147289.html
Copyright © 2020-2023  润新知