java - android浮动框问题
ringa_lee
ringa_lee 2017-04-17 18:00:36
0
1
576

在界面上加了一个浮动框来模拟鼠标 用另一个手机来控制 移动 怎么让这个鼠标移出屏幕啊 好像怎么都移不出去啊

mWM = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
        ivCursor = new ImageView(getBaseContext());
        ivCursor.setImageResource(R.drawable.mouse);

        mParams = new WindowManager.LayoutParams();// 对ivCursor对象的参数描述对象
        mParams.height = WindowManager.LayoutParams.WRAP_CONTENT;// 宽度自适应
        mParams.width = WindowManager.LayoutParams.WRAP_CONTENT;// 高度自适应
        mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;// 设置成不能获取焦点
        mParams.type = LayoutParams.TYPE_PHONE;
        // 设置图片格式,效果为背景透明
        mParams.format = PixelFormat.RGBA_8888;
        mParams.gravity = Gravity.TOP | Gravity.LEFT;
        // mParams.gravity = Gravity.CENTER;
        Display display = getWindowManager().getDefaultDisplay();
        int w = display.getWidth() / 2;
        int h = display.getHeight() / 2;
        mParams.x = (int) (clientwidth / 2);// 相对于屏幕原点的x轴距离
        mParams.y = (int) (clientheight / 2);// 相对于屏幕原点的y轴距离
        mWM.addView(ivCursor, mParams);
ringa_lee
ringa_lee

ringa_lee

reply all(1)
伊谢尔伦

You can try WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS.

mParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template