android手电筒开发
最近学习android开发,记录学习过程,分享一写小案例
一. 如下先设置好布局文件
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="59dp"
- android:text="欢迎使用"
- android:textSize="40sp" />
- <Button
- android:id="@+id/button1"
- android:onClick="clickRed"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:text="红"
- />
- <Button
- android:id="@+id/button2"
- android:onClick="clickGreen"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/button1"
- android:layout_alignBottom="@+id/button1"
- android:layout_centerHorizontal="true"
- android:text="绿"
- />
- <Button
- android:id="@+id/button3"
- android:onClick="clickBlue"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/button2"
- android:layout_alignBottom="@+id/button2"
- android:layout_alignRight="@+id/textView1"
- android:text="蓝"
- />
二 关键java代码 设置用getWindow().setBackgroundDrawable设置全局颜色
- public void clickRed(View view) {
- getWindow().setBackgroundDrawable(new ColorDrawable(Color.RED));
- }
- public void clickBlue(View view) {
- getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLUE));
- }
- public void clickGreen(View view) {
- getWindow().setBackgroundDrawable(new ColorDrawable(Color.GREEN));
- }
运行效果 如下
源码在这里 喜欢的拿去研究 点击下载
android手电筒开发的更多相关文章
- android平台手电筒开发源代码
android平台手电筒开发源代码,AndroidManifest.xml文件的入口是startapp,这个文件没上传上来,大家可以自己写. 1. [代码]android 1 2 3 4 5 6 7 ...
- Android N开发 你需要知道的一切
title: Android N开发 你需要知道的一切 tags: Android N,Android7.0,Android --- 转载请注明出处:http://www.cnblogs.com/yi ...
- Android游戏开发实践(1)之NDK与JNI开发03
Android游戏开发实践(1)之NDK与JNI开发03 前面已经分享了两篇有关Android平台NDK与JNI开发相关的内容.以下列举前面两篇的链接地址,感兴趣的可以再回顾下.那么,这篇继续这个小专 ...
- Android游戏开发实践(1)之NDK与JNI开发01
Android游戏开发实践(1)之NDK与JNI开发01 NDK是Native Developement Kit的缩写,顾名思义,NDK是Google提供的一套原生Java代码与本地C/C++代码&q ...
- Android游戏开发实践(1)之NDK与JNI开发02
Android游戏开发实践(1)之NDK与JNI开发02 承接上篇Android游戏开发实践(1)之NDK与JNI开发01分享完JNI的基础和简要开发流程之后,再来分享下在Android环境下的JNI ...
- 【转】Android 底层开发的几点
我干了3年Android sdk开发,觉得到了瓶劲没法更进一步,于是花了一年多点时间,大概摸到点门径.根据前辈的经验,Android底层完全入门需要两年. 先说下我的入门过程:第零步,下载源码,我下的 ...
- 《Android NFC 开发实战详解 》简介+源码+样章+勘误ING
<Android NFC 开发实战详解>简介+源码+样章+勘误ING SkySeraph Mar. 14th 2014 Email:skyseraph00@163.com 更多精彩请直接 ...
- Android安全开发之安全使用HTTPS
Android安全开发之安全使用HTTPS 1.HTTPS简介 阿里聚安全的应用漏洞扫描器中有证书弱校验.主机名弱校验.webview未校验证书的检测项,这些检测项是针对APP采用HTTPS通信时容易 ...
- Android安全开发之通用签名风险
Android安全开发之通用签名风险 作者:伊樵.舟海.呆狐@阿里聚安全 1 通用签名风险简介 1.1 Android应用签名机制 阿里聚安全漏洞扫描器有一项检测服务是检测APP的通用签名风险.And ...
随机推荐
- linux 命令行更新sdk
./android list sdk --proxy-host android-mirror.bugly.qq.com --proxy-port 8080 --no-ui -a -s ./androi ...
- UITableView 小节-备
UITableView 让列表自动滑动(定位)到某一行 NSIndexPath*scrollIndexPath = [NSIndexPathindexPathForRow:10inSection:0] ...
- Android实现三级联动下拉框 下拉列表spinner
Android实现(省.市.县)三级联动下拉框 下拉列表spinner 转载请注明出处: http://www.goteny.com/articles/2013/11/46.html http://w ...
- WPF 自己动手来做安装卸载程序
原文:WPF 自己动手来做安装卸载程序 前言 说起安装程序,这也许是大家比较遗忘的部分,那么做C/S是小伙伴们,难道你们的程序真的不需要一个炫酷的安装程序么? 声明在先 本文旨在教大家以自己的方式实现 ...
- SQL查询优化
在数据库SQL性能优化中,查询优化所占比较高.select调优基本还是比较耗时的.所以我整理了一些提示.每当我在写查询语句的时候,总会看看是否满足这些提示清单. 1.要为WHERE 和JOIN后面的字 ...
- 为何某些公司不允许使用C++ STL?
说几个STL的缺点吧,虽然都是在比较极端的情况下出现,但是对于一些大项目还是会遇到的 1. 代码膨胀问题每一个实例化过的模板类,都会膨胀出一份独立的代码,比如std::vector<std::s ...
- YII 事件event和行为Behavior
To declare an event in your CComponent child class, you should add a method with aname starting with ...
- Effective C++笔记(一)——条款26-29
条款26:尽可能延后变量定义式的出现时间 为何要尽量延后? 当程序中途跳出而导致变量未被使用,但是必须进行构造和析构. 最佳初始化变量 直接在构造时指定初值比构造之后再赋值效率高(条款4) ... s ...
- sigaction函数的使用
sigaction函数的功能是检查或修改与指定信号相关联的处理动作(可同时两种操作). 他是POSIX的信号接口,而signal()是标准C的信号接口(如果程序必须在非POSIX系统上运行,那么就应该 ...
- You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApcAAAB3CAIAAADZ1fxtAAAbFElEQVR4nO2dzbHDOo6FHY9S0WqqZt