ftelnov
ftelnov

Reputation: 121

Make constraint layout untouchable

I have two layouts, manageLayout and mainLayout. They have constraints to the parent on all sides. I need in a one time have manageLayout on the top of mainLayout, and on the other time mainLayout on the top of manageLayout. Of course, there is sense in using visibility=gone on one of them, but i need one layout on the background of another. Problem: layout on the background handle events from top layout. How to make lower layout(and his elements) untouchable when another layout is risen? Layout tree image: LayoutTreeImg Code sample, where i want to disable communications with lower layout: https://pastebin.com/PeL7u3YD (not only isSaveEnabled=false had no effect, also isEnabled=false had no effects too)

Upvotes: 1

Views: 373

Answers (2)

Harjinder Bains
Harjinder Bains

Reputation: 406

According to my perception, you can make lower layout setEnable(false). I hope it will work.

Upvotes: 0

ljk
ljk

Reputation: 1616

If you just need an explanation.

Once you've initialized both your views for mainLayout and manageLayout, you will need to set an empty onClickListener on both of them. Basically, layouts should get the click but do nothing. This way you can block the layout and widgets underneath the view on Front from getting clicked.

Now for for switching view to front maintain a boolean to know which view is on the front and on your button click set the other view bringToFront() (Or try some other ways mentioned here if you want) and don't forget to switch the boolean value.

Let me know if this works for you or you have any issues regarding this.

Upvotes: 1

Related Questions