开发者

Can I make a "layer"

开发者 https://www.devze.com 2023-03-17 02:15 出处:网络
Is there any way to create a view above all the others,so when this view is visible, I cannot interact with other views except this one. 开发者_开发知识库Sounds like a lock screen.And yeah,that\'s wha

Is there any way to create a view above all the others,so when this view is visible, I cannot interact with other views except this one. 开发者_开发知识库Sounds like a lock screen.And yeah,that's what I really want to achieve. Any suggestion?


Use a RelativeLayout which fills parent both in width and height. Let this layout have a child view which could be any view.

Put the view on top and set a onTouchlistener.

 view.bringToFront();
 view.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                return true;
            }

        });

That is, have a touch listener that takes all touch events and consumes them (return true).


Use RelativeLayout and ViewGroup.bringChildToFront for the View you want to be above all others.

When adding element to RelativeLayout set layout_height and layout_width to 'match_parent'

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号