



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Android中使用颜色资源的完成调色板项目的代码清单范美英(北京信息职业技术学院)摘 要:Android应用开发中经常会使用到颜色资源用来实现UI的效果,本文详细罗列了使用颜色资源完成调色板项目的代码清单。关键词: Android;颜色资源;调色板;代码清单1 MainActivity.java类的代码public class MainActivity extends Activity EditText edt_a,edt_r,edt_g,edt_b;LinearLayout color_res;Overrideprotected void onCreate(Bundle savedInst
2、anceState) super.onCreate(savedInstanceState);public void clickOK(View v)int alpha=Integer.parseInt(edt_a.getText().toString();int red=Integer.parseInt(edt_r.getText().toString();int green=Integer.parseInt(edt_g.getText().toString();int blue=Integer.parseInt(edt_b.getText().toString();if(alpha>25
3、5|alpha<0)edt_a.getText().clear();edt_a.requestFocus();elseif(red>255|red<0)edt_r.getText().clear();edt_r.requestFocus();elseif(green>255|green<0)edt_g.getText().clear();edt_g.requestFocus();elseif(blue>255|blue<0)edt_b.getText().clear();edt_b.requestFocus();elseint color=Color.
4、argb(alpha, red, green, blue);color_res.setBackgroundColor(color);2 res/layout/activity_main.xml的代码清单 android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="+id/edt_alpha" android:lay
5、out_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="请输入透明度值(0255)" android:inputType="number" > <requestFocus /> </EditText> <EditText android:id="+id/edt_r" android:layout_width=&q
6、uot;match_parent" android:layout_height="wrap_content" android:hint="请输入Red值(0255)" android:ems="10" android:inputType="number" /> <EditText android:id="+id/edt_g" android:layout_width="match_parent" android:layout_height="w
7、rap_content" android:ems="10" android:hint="请输入Green值(0255)" android:inputType="number" /> <EditText android:id="+id/edt_b" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入Blue值(0255
8、)" android:ems="10" android:inputType="number" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"> <Button android:id="+id/button1" android:layout_width="
9、wrap_content" android:layout_height="wrap_content" android:text="确定" android:onClick="clickOK" /> </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="调色结果:" andro
10、id:textAppearance="?android:attr/textAppearanceLarge" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="+id/color_res" android:orientation="horizontal" > </LinearLayout> </LinearLayout>3 res/menu/activity_main.xml的代码清单 <item android:id="+id/menu_settings" android:orderInCategory=&quo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 加班夜宵采购合同范本
- 单位间借用合同范本
- 个人股东入股合同范本
- 保安公司加盟合同范本
- 产学研技术采购合同范本
- 劳务聘用员工合同范本
- 企业绿化采购合同范本
- 加工中心租赁合同范本
- 劳务协议解除合同范本
- 公司股权集资合同范本
- 高中雷雨完整省公开课金奖全国赛课一等奖微课获奖课件
- 药物超敏反应综合征并人类免疫缺陷病毒感染1例及文献复习
- GB/T 43635-2024法庭科学DNA实验室检验规范
- 《社区康复》课件-第五章 脊髓损伤患者的社区康复实践
- 2024年01月北京市地质矿产勘查院所属事业单位招考聘用笔试历年高频考题(难、易错点荟萃)答案带详解附后
- 新产品开发(toshiba案例分析组)
- 网络传播概论(彭兰第5版) 课件全套 第1-8章 网络媒介的演变-网络传播中的“数字鸿沟”
- 4.1.1 有理数指数幂-参考课件
- 雷达简介讲解课件
- 人教版六年级数学下册全册大单元教学任务单
- 口服止痛药物健康宣教
评论
0/150
提交评论