当前位置: 编程技术>移动开发
本页文章导读:
▪给图片的边沿加上光晕 给图片的边缘加上光晕
ImageView v = (ImageView)findViewById(R.id.image);//一定要给ImageView加上几个像素的Padding,要不然效果出来不了
Paint p= new Paint();
p.setColor(Color.RED);//红色的光晕
BitmapDrawable bd = (Bitma.........
▪ 擒获Home键按下 捕获Home键按下
在Activity界面重写onAttachedToWindow方法@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}switch (keyCode) {
case.........
▪ Activity其间切换的各种效果(遗憾没有3D的效果)(转载) Activity之间切换的各种效果(遗憾没有3D的效果)(转载)
下面的Demo是我找到的一个觉得用来在程序中进行Activity之间切换的很好的一个例子:package com.asai.android.demo;
import android.app.Activity;
import a.........
[1]给图片的边沿加上光晕
来源: 互联网 发布时间: 2014-02-18
给图片的边缘加上光晕
参考http://gundumw100.iteye.com/blog/1205547#comments
ImageView v = (ImageView)findViewById(R.id.image);//一定要给ImageView加上几个像素的Padding,要不然效果出来不了 Paint p= new Paint(); p.setColor(Color.RED);//红色的光晕 BitmapDrawable bd = (BitmapDrawable) v.getDrawable(); Bitmap b = bd.getBitmap(); Bitmap bitmap = Bitmap.createBitmap(bd.getIntrinsicWidth(), bd.getIntrinsicHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(b.extractAlpha(), 0, 0, p); StateListDrawable sld = new StateListDrawable(); sld.addState(new int[]{android.R.attr.state_pressed}, new BitmapDrawable(bitmap)); v.setBackgroundDrawable(sld);
参考http://gundumw100.iteye.com/blog/1205547#comments
[2] 擒获Home键按下
来源: 互联网 发布时间: 2014-02-18
捕获Home键按下
在Activity界面重写onAttachedToWindow方法
在Activity界面重写onAttachedToWindow方法
@Override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); }
switch (keyCode) { case KeyEvent.KEYCODE_HOME: Log.i(TAG,"KEYCODE_HOME"); Toast.makeText(Test1Activity.this, "你按下了Home键", Toast.LENGTH_SHORT).show(); return true;
1 楼
bingtao115
2011-11-08
真的可以捕获到home按键的事件,太好了,找了好久
2 楼
ylzyd12345
2011-12-07
。。。。前一段时间还有人问这个问题呢。。。
[3] Activity其间切换的各种效果(遗憾没有3D的效果)(转载)
来源: 互联网 发布时间: 2014-02-18
Activity之间切换的各种效果(遗憾没有3D的效果)(转载)
下面的Demo是我找到的一个觉得用来在程序中进行Activity之间切换的很好的一个例子:
另外一个activity可以自己随便写个,这里还用到了就是arrays.xml作为Spinner的适配器:
相信这段代码我不用解释应该也看的懂:改变y坐标来实现动画效果;
相对应的就是:
push_up_out.xml:
里面实在太多了,我直接贴上附件,需要的可以自己下了学习
下面的Demo是我找到的一个觉得用来在程序中进行Activity之间切换的很好的一个例子:
package com.asai.android.demo; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; public class demoMain extends Activity { private Button btnDemo; private Spinner sprAnim; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btnDemo = (Button) findViewById(R.id.btnDemo); sprAnim = (Spinner) findViewById(R.id.sprAnim); //Spinner的内容适配器 ArrayAdapter<?> animType = ArrayAdapter.createFromResource(this, R.array.anim_type, android.R.layout.simple_spinner_item); animType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sprAnim.setAdapter(animType); //默认选中第一项 sprAnim.setSelection(0); btnDemo.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startActivity(new Intent(demoMain.this, demoDetail.class)); switch (sprAnim.getSelectedItemPosition()) { case 1: //淡入淡出效果 overridePendingTransition(R.anim.fade, R.anim.hold); break; case 2: overridePendingTransition(R.anim.alpha_rotate, R.anim.my_alpha_action); break; case 3: overridePendingTransition(R.anim.alpha_scale_rotate, R.anim.my_alpha_action); break; case 4: overridePendingTransition( R.anim.alpha_scale_translate_rotate, R.anim.my_alpha_action); break; case 5: overridePendingTransition(R.anim.alpha_scale_translate, R.anim.my_alpha_action); break; case 6: //中心放大效果 overridePendingTransition(R.anim.alpha_scale, R.anim.my_alpha_action); break; case 7: overridePendingTransition(R.anim.alpha_translate_rotate, R.anim.my_alpha_action); break; case 8: overridePendingTransition(R.anim.alpha_translate, R.anim.my_alpha_action); break; case 9: overridePendingTransition(R.anim.my_rotate_action, R.anim.my_alpha_action); break; case 10: overridePendingTransition(R.anim.my_scale_action, R.anim.my_alpha_action); break; case 11: overridePendingTransition(R.anim.my_translate_action, R.anim.my_alpha_action); break; case 12: overridePendingTransition(R.anim.myanimation_simple, R.anim.my_alpha_action); break; case 13: overridePendingTransition(R.anim.myown_design, R.anim.my_alpha_action); break; case 14: overridePendingTransition(R.anim.scale_rotate, R.anim.my_alpha_action); break; case 15: overridePendingTransition(R.anim.scale_translate_rotate, R.anim.my_alpha_action); break; case 16: overridePendingTransition(R.anim.scale_translate, R.anim.my_alpha_action); break; case 17: overridePendingTransition(R.anim.translate_rotate, R.anim.my_alpha_action); break; case 18: overridePendingTransition(R.anim.hyperspace_in, R.anim.hyperspace_out); break; case 19: overridePendingTransition(R.anim.shake, R.anim.my_alpha_action); break; case 20: overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out); break; case 21: //从下方移出效果 overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out); break; case 22: overridePendingTransition(R.anim.slide_left, R.anim.slide_right); break; case 23: overridePendingTransition(R.anim.slide_top_to_bottom, R.anim.my_alpha_action); break; case 24: overridePendingTransition(R.anim.wave_scale, R.anim.my_alpha_action); break; } } }); } }
另外一个activity可以自己随便写个,这里还用到了就是arrays.xml作为Spinner的适配器:
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="anim_type"> <item>zoom_enter</item> <item>fade</item> <item>alpha_rotate</item> <item>alpha_scale_rotate</item> <item>alpha_scale_translate_rotate</item> <item>alpha_scale_translate</item> <item>alpha_scale</item> <item>alpha_translate_rotate</item> <item>alpha_translate</item> <item>my_rotate_action</item> <item>my_scale_action</item> <item>my_translate_action</item> <item>myanimation_simple</item> <item>myown_design</item> <item>scale_rotate</item> <item>scale_translate_rotate</item> <item>scale_translate</item> <item>translate_rotate</item> <item>hyperspace_in</item> <item>shake</item> <item>push_left_in</item> <item>push_up_in</item> <item>slide_left</item> <item>slide_top_to_bottom</item> <item>wave_scale</item> </string-array> </resources>
相信这段代码我不用解释应该也看的懂:改变y坐标来实现动画效果;
相对应的就是:
push_up_out.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" /> </set>
里面实在太多了,我直接贴上附件,需要的可以自己下了学习
最新技术文章: