Android Resize View in Windowmanager

与世无争的帅哥 提交于 2019-12-07 17:50:42

问题


Here is my code :


        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);

I have a Layout added to the windowmanager, and I want to resize it to fill the screen, Can I do this ?

来源:https://stackoverflow.com/questions/20829800/android-resize-view-in-windowmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!