1

I have Two children on a FrameLayout, a view pager and a backround view I add the background view as a second child , so it's supposed to be on top of my view pager.

The problem is I can still scroll my view pager despite of having another view on top of it.

the structure is :

<FrameLayout>

   <DrawerLayout>contains view pager and content</DrawerLayout>
   <LinearLayout></LinearLayout> -> this is where I add my view as a black background

</FrameLayout>

How do I disable the input and listener for the first child of the framelayout or is there an easier way of doing this?

Tried setting the elevation, and bringViewToFront(), but those aren't working.

Thanks

HassanUsman
  • 1,787
  • 1
  • 20
  • 38
Karate_Dog
  • 1,265
  • 5
  • 20
  • 37

2 Answers2

1

You can disable focus on framelayout and enable focus on child views. See if this helps you.

framelayout.setFocusable(false);
framelayout.setFocusableInTouchMode(false);

Set focusable to true for drawerlayout and linearlayout. Hope this helps.

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
0

I think I have found the answer. Been lurking on stack overflow a bit and found the answer on this

Overlaying a view does not disable actions on underlying view

It is stated by nizammoidu that an underlying view (behind view) will instead intercept the touch event if the front view is not consuming the touch event.

So the solution is by giving the top view (in my case LinearLayout) clickable parameter to true

android:clickable:true

or

view.setClickable(true);
Community
  • 1
  • 1
Karate_Dog
  • 1,265
  • 5
  • 20
  • 37