Android棒棒糖接触色 [英] Android lollipop contact color

查看:74
本文介绍了Android棒棒糖接触色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何选择联系人徽章的颜色.使用什么算法?

How do select color of contact badge. What algorithm using?

推荐答案

它不保存.它使用联系人姓名字符串的哈希码确定颜色.

It does not save. It uses the hashcode of the Contact name string to determine the color.

示例:

String name = "Harish";
int colors[] = new int[] { Color.RED, Color.GREEN, Color.BLUE};

int chosenColor = colors[Math.abs(name.hashCode()) % colors.length];

我从 answer

这篇关于Android棒棒糖接触色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆