1

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)

ftelnov
  • 111
  • 1
  • 8
  • Can you provide relevant source code? Any chance this answers your question: https://stackoverflow.com/a/34391262? – stefita Mar 04 '20 at 08:45
  • Added layout tree to post, i don't understand, for what i need paste code - all the problem described in the post. – ftelnov Mar 04 '20 at 08:49
  • This answer is about how to make one layout in the top of other. I have already done with it using `visibility=gone\visible`, but I am still able to communicate with lower layout – ftelnov Mar 04 '20 at 10:37

2 Answers2

1

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.

ljk
  • 1,496
  • 1
  • 11
  • 14
  • I think, it can be replace by setting `isClickable=false` to lower layout, but it had no effect - i am able to communicate with lower layout. Let me bring some remarks to answer - i bring layout to the top of other using `visibility=gone` or `visibility=visible` to manageLayout. – ftelnov Mar 04 '20 at 10:33
  • The view placed on top must intercept the views on the lower one. That is the reason you need a clickListener on the view onFront. If you replace that lower layout will get the click, is that what you meant? – ljk Mar 04 '20 at 10:45
  • I need for lower layout NOT get top layout's clicks – ftelnov Mar 04 '20 at 10:46
  • With regards to your question "How to make lower layout(and his elements) untouchable when another layout is risen?" is what I am trying to say, if your "risen layout" covers the whole screen as you mentioned you just need to set a click listener on that "risen layout" so that clicking prevents all clicks on lower layout. – ljk Mar 04 '20 at 10:56
0

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

Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53
Harjinder Bains
  • 356
  • 3
  • 7