SlidingPaneLayout - touch event is delegated to the view behind - android

How can I avoid that my SlidingPaneLayout delegates the touch event to the behind view?
In my case, if a non touchable area like a textview is over a button and the behind view is not visible and I touch the textview, the button get's the touch event...

I know it's late, but for other people searching for the same issue:
I use
android:clickable="true"
in the xml of the view that is non-touchable. For example, if you have a FrameLayout corresponding to the detail pane, then set its clickable value to true. Then it won't pass the touch events to the view behind(master pane).

Related

How to prevent the touch event from view to another view?

If I have a scrollview and a subview.
in the subview I add a touch effect so that I can get the touch position.
but the scrollview will also receive the touch event.
how to prevent it?
if I touch the screen from top to bottom to the subview then the page will scroll.
You can use nested scroll view instead of scroll view to prevent touch events on it.

Custom View: swipe inside of scroll view

I created a custom View with Canvas and made it interactivly with overwriteing onTouchEvent.
But my view is inside of a ScrollView. It losts the focus while i drag/swipe an item to the right side in my custom view and move my finger a little bit up or down. Then the ScrollView react and my view never get an ACTION_UP Event.
Is there a way to avoid that the scrollView-Parent scolls while i interact with my custom view?
You need ViewParent.requestDisallowInterceptTouchEvent
https://developer.android.com/reference/android/view/ViewParent#requestDisallowInterceptTouchEvent(boolean)
In your custom view, once it has detected the touch gesture is for it, call scrollview.requestDisallowInterceptTouchEvent(true). The scrollview will then ignore further events for the duration of the touch i.e. until it (the scrollview) receives an ACTION_UP or ACTION_CANCEL event.

How to disable the listener and input on First view FrameLayout

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
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.
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);

top view's touch also works it's bottom view's touch

Hi I am facing such issue,
I have two view for example my first view is A which's image is below
and I am opening View B on this A view
In view B when i touch the area where there is no button for example
it's affect to View A, means A view's button clicked, how to avoid this can any body help?
thanks
Since the background of the keyboard isn't clickable it goes through to the next layer. Simply set the background/panel of the keyboard as clickable by android:clickable="true", this will prevent the lower layer from being clicked.

Overlaying a view does not disable actions on underlying view

I have 2 views : View A and view B. View A is rendered and has actions to input a text value. Im displaying an overlay view - View B on top of this. I expect that the actions on View A get disabled but they do not and im still able to type in the input field on View A. How can i disable this ?
The reason is that your overlay is not consuming the touch events , so by design if a view is not consuming touch events the events are passed to underlying view in the view model. So the long answer is make your overlay touchable, focusable , and touch listener and return true . short answer is add android:clickable="true" to your overlay view.

Categories

Resources