
颜色值怎么转换为drawable
2个回答
展开全部
按你问题的问法,你的需求有点困难...
drawable中存放的是图片资源,如果你获取一个彩虹图片的颜色值...
如果按照你的问题,一定非要解决的话,需要加条件
其一:纯色;
其二,你要对底层输入输出流很!透彻;
那可能性不高...
so,你的问题可以改成获取一个纯色的且非图片的背景的颜色值
源码是这样定义颜色背景的
public void setBackgroundColor(int color) {
setBackgroundDrawable(new ColorDrawable(color));
}
ColorDrawable是个继承Drawable的东西,这里面有个这么个方法
/**
* Returns the alpha value of this drawable's color.
*
* @return A value between 0 and 255.
*/
public int getAlpha() {
return mState.mUseColor >>> 24;
}
应该是你想要的~
drawable中存放的是图片资源,如果你获取一个彩虹图片的颜色值...
如果按照你的问题,一定非要解决的话,需要加条件
其一:纯色;
其二,你要对底层输入输出流很!透彻;
那可能性不高...
so,你的问题可以改成获取一个纯色的且非图片的背景的颜色值
源码是这样定义颜色背景的
public void setBackgroundColor(int color) {
setBackgroundDrawable(new ColorDrawable(color));
}
ColorDrawable是个继承Drawable的东西,这里面有个这么个方法
/**
* Returns the alpha value of this drawable's color.
*
* @return A value between 0 and 255.
*/
public int getAlpha() {
return mState.mUseColor >>> 24;
}
应该是你想要的~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询