android 特殊用法二
来源:互联网 发布:淘宝推广网站有哪些 编辑:程序博客网 时间:2024/05/17 02:30
9.创建一个圆角图片
这个的主要原理其实就是利用遮罩,先创建一个圆角方框 然后将图片放在下面:
1. Bitmap myCoolBitmap = ... ;
2. int w = myCoolBitmap.getWidth(), h = myCoolBitmap.getHeight();
3. Bitmap rounder = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
4. Canvas canvas = new Canvas(rounder);
5. Paint xferPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
6. xferPaint.setColor(Color.RED);
7. canvas.drawRoundRect(new RectF(0,0,w,h), 20.0f, 20.0f, xferPaint);
8. xferPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
1. //然后呢实现
2. canvas.drawBitmap(myCoolBitmap, 0,0, null);
3. canvas.drawBitmap(rounder, 0, 0, xferPaint);
10.在notification 上的icon上加上数字 给人提示有多少个未读
1. Notification notification = new Notification (icon, tickerText, when);
2. notification .number = 4;
11背景渐变:
首先建立文件drawable/shape.xml
1. <?xml version="1.0" encoding="utf-8"?>
2. <shape xmlns:android ="http://schemas.android .com/apk/res/android " android :shape="rectangle">
3. <gradient android :startColor="#FFFFFFFF" android :endColor="#FFFF0000"
4. android :angle="270"/>
5. </shape>
在该文件中设置渐变的开始颜色(startColor)、结束颜色(endColor)和角度(angle)
接着创建一个主题values/style.xml
1. <?xml version="1.0" encoding="utf-8"?>
2. <resources>
3. <style name="NewTheme" parent="android :Theme">
4. <item name="android :background">@drawable/shape</item>
5. </style>
6. </resources>
然后在AndroidManifest.xml文件中的application或activity中引入该主题,如:
1. <activity android :name=".ShapeDemo" android :theme="@style/NewTheme">
该方法同样适用于控件 http://17f8.cn/trackback.php?tbID=259&extra=9d45e9
12. 储存数据 当你在一个实例中保存静态数据,此示例关闭后 下一个实例想引用 静态数据就会为null,这里呢必须重写applition
1. public class MyApplication extends Application{
2. private String thing = null;
3. public String getThing(){
4. return thing;
5. }
6. public void setThing( String thing ){
7. this.thing = thing; }
8. }
9. public class MyActivity extends Activity {
10. private MyApplication app;
11. public void onCreate(Bundle savedInstanceState) {
12. super.onCreate(savedInstanceState);
13. app = ((MyApplication)getApplication());
14. String thing = app.getThing();
15. }
- android 特殊用法二
- android 特殊用法琐碎二
- Android 特殊用法
- android 特殊用法一
- android特殊用法
- android EditText的特殊用法
- It的几种特殊用法二
- It的几种特殊用法二
- 类的特殊用法(二)super
- Android ListView 特殊属性及用法
- android AsyncTask 在项目中的特殊用法
- 一些android代码的特殊用法
- Android TextView的一些特殊用法
- Android synchronized用法二
- android 特殊用户通知用法汇总--Notification源码分析
- android 特殊用户通知用法汇总--Notification源码分析
- Android 特殊用户通知用法汇总 - Notification 源码分析
- Android ListView常用用法(二)
- android 特殊用法一
- 2011.12.7 一个研究生毕业后的职业规划 -----我今年39岁了,25岁研究生毕业,工作14年,回头看看,应该说走了不少的弯路,有一些经验和教训。
- redirect uri is illegal(100010)!
- 修改MFC的图标
- 一个由C/C++编译的程序占用的内存分为以下几个部分
- android 特殊用法二
- man 命令的使用
- 虚基类 和 虚函数
- 利用GPO开启管理共享admin$
- 定制自己的eversecOS
- Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
- 二叉树的非递归遍历
- 插入多行数据——存储过程加函数
- 2012中小企业为什么需要搜索引擎营销?