- 浏览: 3909530 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
hinuliba:
...
字体背景颜色的高度修改 -
KANGOD:
最后的 -createDialog() 私有方法是怎么回事,没 ...
简单的实现listView中item多个控件以及点击事件 -
sswangqiao:
呵呵,呵呵
onActivityResult传值的使用 -
yumeiqiao:
感觉你所的不清楚 lstView.setOnTouchLi ...
listview中viewflipper的问题 -
lizhou828:
果然是大神啊!!!
Animation动画效果的实现
1.让一个图片透明:
Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);
2.直接发送邮件:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "test@test.com", null));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
3.程序控制屏幕变亮:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);
4.过滤特定文本
Filter filter = myAdapter.getFilter();
filter.filter(mySearchText);
5scrollView scroll停止事件
setOnScrollListener(new OnScrollListener(){
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub }
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState == 0) Log.i("a", "scrolling stopped..."); } });}
6. 对于特定的程序 发起一个关联供打开
Bitmap bmp = getImageBitmap(jpg);
String path = getFilesDir().getAbsolutePath() + "/test.png";
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
bmp.compress( CompressFormat.PNG, 100, fos );
fos.close();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
对于图片上边的不适用索引格式会出错。
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/test.mp4");
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/test.mp3");
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
7.设置文本外观
setTextAppearance(context, android.R.style.TextAppearance_Medium);
android:textAppearance="?android:attr/textAppearanceMedium"
8.设置单独的发起模式:
<activity
android:name=".ArtistActivity"
android:label="Artist"
android:launchMode="singleTop">
</activity>
Intent i = new Intent();
i.putExtra(EXTRA_KEY_ARTIST, id);
i.setClass(this, ArtistActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
9.创建一个圆角图片
这个的主要原理 其实就是 利用遮罩,先创建一个圆角方框 然后将图片放在下面:
Bitmap myCoolBitmap = ... ;
int w = myCoolBitmap.getWidth(), h = myCoolBitmap.getHeight();
Bitmap rounder = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(rounder);
Paint xferPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
xferPaint.setColor(Color.RED);
canvas.drawRoundRect(new RectF(0,0,w,h), 20.0f, 20.0f, xferPaint);
xferPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
然后呢实现
canvas.drawBitmap(myCoolBitmap, 0,0, null);
canvas.drawBitmap(rounder, 0, 0, xferPaint);
10 在notification上的icon上加上数字 给人提示有多少个未读
Notification notification = new Notification(icon, tickerText, when);
notification.number = 4;
11背景渐变:
首先建立文件drawable/shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFFFFFF" android:endColor="#FFFF0000"
android:angle="270"/>
</shape>
在该文件中设置渐变的开始颜色(startColor)、结束颜色(endColor)和角度(angle)
接着创建一个主题values/style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NewTheme" parent="android:Theme">
<item name="android:background">@drawable/shape</item>
</style>
</resources>
然后在AndroidManifest.xml文件中的application或activity中引入该主题,如:
<activity android:name=".ShapeDemo" android:theme="@style/NewTheme">
该方法同样适用于控件 http://17f8.cn/trackback.php?tbID=259&extra=9d45e9
12. 储存数据 当你在一个实例中保存静态数据,此示例关闭后 下一个实例想引用 静态数据就会为null,这里呢必须重写applition
public class MyApplication extends Application{
private String thing = null;
public String getThing(){
return thing;
}
public void setThing( String thing ){
this.thing = thing; }
}
public class MyActivity extends Activity {
private MyApplication app;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = ((MyApplication)getApplication());
String thing = app.getThing();
}
}
Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);buffer.eraseColor(Color.TRANSPARENT);
2.直接发送邮件:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "test@test.com", null));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
3.程序控制屏幕变亮:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 100 / 100.0f;
getWindow().setAttributes(lp);
4.过滤特定文本
Filter filter = myAdapter.getFilter();
filter.filter(mySearchText);
5scrollView scroll停止事件
setOnScrollListener(new OnScrollListener(){
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub }
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState == 0) Log.i("a", "scrolling stopped..."); } });}
6. 对于特定的程序 发起一个关联供打开
Bitmap bmp = getImageBitmap(jpg);
String path = getFilesDir().getAbsolutePath() + "/test.png";
File file = new File(path);
FileOutputStream fos = new FileOutputStream(file);
bmp.compress( CompressFormat.PNG, 100, fos );
fos.close();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png");
startActivity(intent);
对于图片上边的不适用索引格式会出错。
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/test.mp4");
intent.setDataAndType(Uri.fromFile(file), "video/*");
startActivity(intent);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/test.mp3");
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
7.设置文本外观
setTextAppearance(context, android.R.style.TextAppearance_Medium);
android:textAppearance="?android:attr/textAppearanceMedium"
8.设置单独的发起模式:
<activity
android:name=".ArtistActivity"
android:label="Artist"
android:launchMode="singleTop">
</activity>
Intent i = new Intent();
i.putExtra(EXTRA_KEY_ARTIST, id);
i.setClass(this, ArtistActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
9.创建一个圆角图片
这个的主要原理 其实就是 利用遮罩,先创建一个圆角方框 然后将图片放在下面:
Bitmap myCoolBitmap = ... ;
int w = myCoolBitmap.getWidth(), h = myCoolBitmap.getHeight();
Bitmap rounder = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(rounder);
Paint xferPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
xferPaint.setColor(Color.RED);
canvas.drawRoundRect(new RectF(0,0,w,h), 20.0f, 20.0f, xferPaint);
xferPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
然后呢实现
canvas.drawBitmap(myCoolBitmap, 0,0, null);
canvas.drawBitmap(rounder, 0, 0, xferPaint);
10 在notification上的icon上加上数字 给人提示有多少个未读
Notification notification = new Notification(icon, tickerText, when);
notification.number = 4;
11背景渐变:
首先建立文件drawable/shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#FFFFFFFF" android:endColor="#FFFF0000"
android:angle="270"/>
</shape>
在该文件中设置渐变的开始颜色(startColor)、结束颜色(endColor)和角度(angle)
接着创建一个主题values/style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="NewTheme" parent="android:Theme">
<item name="android:background">@drawable/shape</item>
</style>
</resources>
然后在AndroidManifest.xml文件中的application或activity中引入该主题,如:
<activity android:name=".ShapeDemo" android:theme="@style/NewTheme">
该方法同样适用于控件 http://17f8.cn/trackback.php?tbID=259&extra=9d45e9
12. 储存数据 当你在一个实例中保存静态数据,此示例关闭后 下一个实例想引用 静态数据就会为null,这里呢必须重写applition
public class MyApplication extends Application{
private String thing = null;
public String getThing(){
return thing;
}
public void setThing( String thing ){
this.thing = thing; }
}
public class MyActivity extends Activity {
private MyApplication app;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = ((MyApplication)getApplication());
String thing = app.getThing();
}
}
发表评论
-
URI 转path
2019-06-26 10:41 1240转自知乎Matisse package com.zhihu ... -
权限申请
2017-09-22 13:25 1231public class PermissionActivit ... -
onPreviewFrame 相机输出格式转换yuv420p保存成图片
2015-11-25 15:59 7494在最近项目中,因为特殊需要,底层相机往外输出了i420 也 ... -
new Android's Runtime Permission
2015-11-03 21:05 1201targetSdkVersion 23 开始 使用运行时权 ... -
自定义listview 边缘效果
2015-02-28 10:58 1713static void ChangeEdgeEffect( ... -
发射打开wifi
2015-01-07 10:25 1380WifiManager wifiManager = (Wif ... -
RecyclerView
2014-11-05 13:08 1223http://www.grokkingandroid.com ... -
获取点击区域
2014-04-28 09:39 1529@Override public void getHitR ... -
speex 和libogg 编译
2014-04-03 16:17 6374下载: http://www.speex.org/down ... -
rsync 同步
2014-03-28 17:06 1811两台android 设备 进行rsy ... -
流转字符串
2014-03-11 09:49 1485public static String convertSt ... -
java simplexml 序列化
2014-03-06 13:22 5900<?xml version="1.0&quo ... -
获取其他程序的特定资源
2014-03-05 09:33 1668try { PackageManager man ... -
检测来电属于哪个sim卡
2014-02-07 10:41 1685public class IncomingCallInter ... -
使用 NDK r9 编译ffmpeg
2014-01-16 13:32 167781. 环境 ubuntu 我的是13.10 ndk r9 ... -
android h264含so
2014-01-13 11:24 1518http://download.csdn.net/downlo ... -
xml转义字符
2013-12-18 09:29 1562" " ' & ... -
字体背景颜色的高度修改
2013-12-11 10:31 4152当使用android:lineSpacingExtra= ... -
屏保的实现
2013-12-07 10:27 2737最近需要做一个屏保,开始以为很简单,因为系统本身就带了屏保功 ... -
PreferenceActivity下嵌套PreferenceScreen在其它布局中
2013-11-21 16:32 9108今天在修改系统代码的时候,系统代码用了PreferenceA ...
相关推荐
它从Android繁杂的源代码中抽取出了Android开发的“精华”和“要点”,剥离了大量琐碎的底层实现细节,进行了高度概括和总结,不仅能帮助开发者迅速地从宏观上理解整个Android系统的设计理念,而且能帮助开发者迅速...
它从Android繁杂的源代码中抽取出了Android开发的“精华”和“要点”,剥离了大量琐碎的底层实现细节,进行了高度概括和总结,不仅能帮助开发者迅速从宏观上理解整个Android系统的设计理念,而且能帮助开发者迅速从...
它从Android繁杂的源代码中抽取出了Android开发的“精华”和“要点”,剥离了大量琐碎的底层实现细节,进行了高度概括和总结,不仅能帮助开发者迅速从宏观上理解整个Android系统的设计理念,而且能帮助开发者迅速从...
许多人没有大量的时间在电脑上网游戏,于是,人们越来越乐意在琐碎的时间里在手机上玩一些小游戏。运行在安卓系统平台的小游戏逐渐收到大众的喜爱。 系统目标: 本系统以Android操作系统作为开发平台,Eclipse作为...
如果你有许多小的文档、编程用的源代码、小图片等等琐碎的东西,弃之可惜,长期放在各个文件夹里又显零乱,偶而要用找起来也麻烦,琐碎打包工具可以帮助你将这些琐碎打包成一个chm文件,还可以加上说明页,既有目录...
它从Android繁杂的源代码中抽取出了Android开发的“精华”和“要点”,剥离了大量琐碎的底层实现细节,进行了高度概括和总结,不仅能帮助开发者迅速从宏观上理解整个Android系统的设计理念,而且能帮助开发者迅速从...
它从Android繁杂的源代码中抽取出了Android开发的“精华”和“要点”,剥离了大量琐碎的底层实现细节,进行了高度概括和总结,不仅能帮助开发者迅速从宏观上理解整个Android系统的设计理念,而且能帮助开发者迅速从...
可以快速,简便清除C盘垃圾,并不留痕迹。
试过很多CHM的制作工具,都不是很好,就这个使用起来方便容易。
数据库表的琐碎知识2.sql
讣告 android capstone 2014 年 10 月电影琐碎应用程序
琐碎二重性
C++学习过程的琐碎点和注意点,不断总结中。
数据库表的琐碎知识.sql
数据库表的琐碎知识3.sql
数据库表的琐碎知识6.sql
数据库表的琐碎知识5.sql
数据库表的琐碎知识4.sql
android_hid 将Android用作针对其他Android设备的Rubber Ducky 使用Android进行HID攻击 将Android用作针对Android的Rubber Ducky。 这不是一项新技术,只是一个演示如何使用Android而不是橡皮鸭来进行HID攻击的演示...
文学的日常 世俗的琐碎里拥有精神