



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Android中使用颜色资源的完成调色板项目的代码清单范美英(北京信息职业技术学院)摘 要:Android应用开发中经常会使用到颜色资源用来实现UI的效果,本文详细罗列了使用颜色资源完成调色板项目的代码清单。关键词: Android;颜色资源;调色板;代码清单1 MainActivity.java类的代码package com.book.thirdtestcolor;import android.app.Activity;import android.graphics.Color;import android.os.Bundle;import android.view.View;import
2、android.widget.EditText;import android.widget.LinearLayout;public class MainActivity extends Activity EditText edt_a,edt_r,edt_g,edt_b;LinearLayout color_res;Overrideprotected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);edt_a=(Ed
3、itText) this.findViewById(R.id.edt_alpha);edt_r=(EditText) this.findViewById(R.id.edt_r);edt_g=(EditText) this.findViewById(R.id.edt_g);edt_b=(EditText) this.findViewById(R.id.edt_b);color_res=(LinearLayout) this.findViewById(R.id.color_res);public void clickOK(View v)int alpha=Integer.parseInt(edt_
4、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>255|alpha<0)edt_a.getText().clear();edt_a.requestFocus();elseif(red>255|red<0)edt_r.getText().cle
5、ar();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.argb(alpha, red, green, blue);color_res.setBackgroundColor(color);2 res/layout/activity_main.xml的代码清单<
6、;LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="+id/edt_alpha" android:layout_width="match_parent" android:layout_height="wrap
7、_content" android:ems="10" android:hint="请输入透明度值(0255)" android:inputType="number" > <requestFocus /> </EditText> <EditText android:id="+id/edt_r" android:layout_width="match_parent" android:layout_height="wrap_content&quo
8、t; android:hint="请输入Red值(0255)" android:ems="10" android:inputType="number" /> <EditText android:id="+id/edt_g" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="请输入
9、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)" android:ems="10" android:inputType="number&q
10、uot; /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"> <Button android:id="+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" a
11、ndroid:text="确定" android:onClick="clickOK" /> </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="调色结果:" android:textAppearance="?android:attr/textAppearanceLarge" /&g
12、t; <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的代码清单<menu xmlns:android=" > <item android:id="+id/menu_settings"
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 剖析国际物流师的重要工作内容试题及答案
- 2024年采购管理技能提升的常见误区试题及答案
- 北京食品经营许可现场核查表、核查意见
- 大豆玉米带状复合种植技术
- 海外仓储的管理与运营试题及答案
- 绒毛膜羊膜炎对子代心血管系统影响的研究进展 2025
- 2025湖北部分挂网药品价格信息调整表
- 2024年国际物流标准化进程试题及答案
- 考试心态调整SCMP试题及答案
- 2025年通信广播有效载荷合作协议书
- 烫伤不良事件警示教育
- 河南省驻马店市泌阳县部分中学联考2024-2025学年八年级下学期3月月考数学试题(原卷版+解析版)
- 2025年湖北幼儿师范高等专科学校单招职业技能测试题库汇编
- 2025年浙江义乌市商城集团招聘笔试参考题库含答案解析
- DZ∕T 0222-2006 地质灾害防治工程监理规范(正式版)
- 愚公移山英文 -中国故事英文版课件
- 枫香精油(征求意见稿)
- 高压配电设备技术标(范本)要点
- 智能垃圾桶设计方案55264
- 2022年北京市专升本英语真题
- 老年泌尿系统疾病
评论
0/150
提交评论