开发者

Can I make a "layer"

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜