码迷,mamicode.com
首页 > 移动开发 > 详细

android随机颜色的获取

时间:2016-05-16 11:01:13      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

    public  static int getRandomColor(){
        Random random=new Random();
        int r=0;
        int g=0;
        int b=0;
        for(int i=0;i<2;i++){
            //       result=result*10+random.nextInt(10);
            int temp=random.nextInt(16);
            r=r*16+temp;
            temp=random.nextInt(16);
            g=g*16+temp;
            temp=random.nextInt(16);
            b=b*16+temp;
        }
        return Color.rgb(r,g,b);
    }

  方法比较笨,不过,可以达到效果

android随机颜色的获取

标签:

原文地址:http://www.cnblogs.com/lanlengran/p/5497199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!