1

I have two relative layouts. One is main page and the other is slider menu which is hidden by default. when I open second layout it comes over the main layout, but the problem is. I have some button in slider menu which are clickable. If i click on that click event happens for that but also click event is occuring for main view's button if button is exactly behind slid view's button. How can i make sure that behind view gets disabled? similar like z-index in HTML

2 Answers2

0

If I understand you correctly, you can disable the view underneath from intercepting the touch events using yourViewUnderneath.requestDisallowInterceptTouchEvent(true). This will work if the view that lies on top is a child of the parent view.

You can read up on it here: https://developer.android.com/reference/android/view/ViewGroup.html#requestDisallowInterceptTouchEvent%28boolean%29

If the underlying view isn't the parent of the view that comes up over it then you can simply use yourViewUnderneath.setClickable(false)

V-PTR
  • 3,183
  • 3
  • 20
  • 21
0

If the second layout is a slider I think the problem is that you are clicking in some point without ClickListener on the secondLayout, and then, the firstLayout manages the click. So, you can put the visibility of the first View to GONE or make all the layout clickable and manage the id of the clicked View.

mreigosa
  • 1
  • 2