Android 代码中设置Color参数
“vaspolyjackey”通过精心收集,向本站投稿了2篇Android 代码中设置Color参数,下面小编为大家整理后的Android 代码中设置Color参数,欢迎阅读与借鉴!
篇1:Android 代码中设置Color参数
今天想绘制一条根据参数颜色动态变化的曲线,参数不固定,因此需要根据参数来获取颜色值,研究了很久,搞了一个通过Paint实现的方案。
Paint 中包含了很多方法对其属性进行设置,主要方法如下:
setAntiAlias: 设置画笔的锯齿效果。setColor: 设置画笔颜色
setARGB: 设置画笔的a,r,p,g值。
setAlpha: 设置Alpha值
setTextSize: 设置字体尺寸。
setStyle. 设置画笔风格,空心或者实心。
setStrokeWidth: 设置空心的边框宽度。
getColor: 得到画笔的颜色
getAlpha: 得到画笔的Alpha值。
我们需要的就是setARGB和getColor。
?
1
2
3
4
5
6
7
8
9
10
11
12
private int getColor(float yourParam) {
int alfa = 120;
int rColor = 255;
int gColor = 255;
int bColor = 255;
/*********
* Your code, change alfa/r/g/b by yourParam
*********/
Paint paint = new Paint;
paint.setARGB(alfa, rColor, gColor, bColor);
return paint.getColor();
}
篇2:Android中代码运行指定的Apk
有时候,当我们编写自己的应用的时候,需要通过代码实现指定的apk,安装指定的主题,或者安装新的apk,可以通过以下方法实现:
private void installAPK(String apkUrl) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(“file://” + apkUrl),
“applicationnd.android.package-archive”);
startActivity(intent);// 安装
}
apkUrl指的是应用的路径,使用Intent打开Apk进行安装,
【Android 代码中设置Color参数】相关文章:






文档为doc格式