Android调整Windowmanager中的视图

时间:2013-12-29 20:35:11

标签: android android-windowmanager

这是我的代码:


        menubuttonClosed = li.inflate(R.layout.menu_button, null);
        menubutton = (ImageButton) menubuttonClosed.findViewById(R.id.menubutton);
        params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,// | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.x = 0;
        params.y = 0;
        params.gravity = Gravity.CENTER;

        menubutton.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:
                    return true;
                case MotionEvent.ACTION_UP:
                                         //Do something here to resize the View
                    return true;
                case MotionEvent.ACTION_MOVE:
                    return true;

                }
                return false;
            }
        });
        windowManager.addView(menubuttonClosed, params);

我在windowmanager中添加了一个Layout,我想调整它以填充屏幕,我可以这样做吗?

0 个答案:

没有答案