Android 小知识点

1:动态改变 layout 大小

 LayoutParams params = myview.getLayoutParams();
 params.width = LinearLayout.LayoutParams.FILL_PARENT;
 params.height = 330;   
 myview.setLayoutParams(params);

2:SurfaceView 刷新时 surfaceView.setZOrderOnTop(true); 可以使 SurfaceView 显示在最上层,多个SurfaceView叠加刷新时需注意

3:Back 和 Home 键监听

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>  Home键需要

@Override

public void onAttachedToWindow() { // Home键需要

 // 注意:此方法和 android全屏设置有冲突,2.1之前好像没冲突,2.2开始就不行了,只能隐藏掉title,状态栏隐藏不掉

 // 有猜测是 android安全机制,防止恶意程序无法操作设备

this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);


super.onAttachedToWindow();
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if (KeyEvent.KEYCODE_BACK == keyCode) {
// android.os.Process.killProcess(android.os.Process.myPid());
System.out.println("------------- onKeyDown KeyEvent.KEYCODE_BACK nothing ");
}
if (KeyEvent.KEYCODE_HOME == keyCode) {
System.out.println("------------- onKeyDown KeyEvent.KEYCODE_HOME nothing ");
}
return super.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (KeyEvent.KEYCODE_BACK == keyCode) {
System.out.println("--- onKeyUp KeyEvent.KEYCODE_BACK nothing ");
}
if (keyCode == KeyEvent.KEYCODE_HOME) {
System.out.println("--- KonKeyUp eyEvent.KEYCODE_HOME nothing ");
}
return super.onKeyUp(keyCode, event);
}
private OnClickListener bt_refresh_lis = new Button.OnClickListener() {
public void onClick(View v) {
refreshFileName();
}
};



你可能感兴趣的:(android,layout,BT)