我想将焦点从视图移动WindowManager
到其他视图以退出应用程序。但我不想使用FLAG_NOT_FOCUSABLE
. 有没有其他方法可以解决这个问题?
例如,
public class WindowManagerTest extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.windowmanagertest);
WindowManager wm = (WindowManager)getSystemService(
Context.WINDOW_SERVICE);
Display dis = wm.getDefaultDisplay();
TextView result = (TextView)findViewById(R.id.result);
Point pt = new Point();
dis.getSize(pt);
result.setText("width = " + pt.x + "\nheight = " + pt.y +
"\nrotate = " + dis.getRotation());
ImageView img = new ImageView(this);
img.setImageResource(R.drawable.clover);
WindowManager.LayoutParams param = new WindowManager.LayoutParams();
param.gravity=Gravity.LEFT | Gravity.TOP;
param.x = 100;
param.y = 20;
param.width = WindowManager.LayoutParams.WRAP_CONTENT;
param.height = WindowManager.LayoutParams.WRAP_CONTENT;
//param.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
param.format = PixelFormat.TRANSLUCENT;
wm.addView(img, param);
}
}