1

I hope someone will help me with this issue:

I've got FrameLayout with two main layers. Video layer, where the streams are broadcasted and on top of it, there is a WebView, which loads a portal (HTML5/CSS/...) with widgets, so it looks like OSD on TV.

When user touches the screen, program info, program channel icon is shown, etc. Touches again, OSD disappear. User can swipe between channels in both directions (infinite loop). All these gestures are performed in WebView, so they're not handled by Android. Communication between portal and Android is done via Javascript interface (enabled on my web view layer).

So far, so good.

When the widgets are hidden, they're not actualy hidden, they're just shown off my tablet screen, because portal area is larger than my web view area. I am using match_parent parameters for height and width.

The actual problem is that sometimes when I do drag by my finger, I manage to scroll the web view (move it) and then I see rest of the portal area, where the widgets are so called hidden.

I wonder how to prevent this happen. I can't disable gestures for the web view, I just want to have it fixed in top left corner without any movement.

I hope someone will be able to help me. Many thanks. Martin

MartinC
  • 546
  • 11
  • 26

1 Answers1

0

Add a listener that does nothing.

webView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event) {
      return (event.getAction() == MotionEvent.ACTION_MOVE);
    }
});

I think you can probably also just use the

webView.setHorizontalScrollBarEnabled(false);

or

webView.setVerticalScrollBarEnabled(false);

[Edit] I should add that if you simply disable the scrollbars you should wrap your webview in a scrollview so it can't actually scroll.

RyanInBinary
  • 1,533
  • 3
  • 19
  • 47
  • Hi Thanks for your answer. 1. If I add a listener as you have suggested, I lose swipe gestures, so changing channels stops working. I also loose two finger drag gesture, which shows and hides EPG widget. Only touch gesture is OK, so I am able to show or hide program info widget by touching the screen. 2. Regarding scrollView, what actually disables the scrolling? I wrapped my webView into scrollView and disabled both scrollbars as you suggested in Activity, but I am able to scroll vertically. I don't think that use of scrollView is a good idea here. – MartinC Jan 06 '13 at 21:00
  • When you wrap a view that scrolls, inside of a scrollview, android can only handle a single view that scrolls... so it generally disables the nested view's scrolling. I can see how the touch override would ruin your javascript and other inputs, but, what made you decide to code a webpage and try to integrate it into android rather than just coding it into android natively? – RyanInBinary Jan 07 '13 at 14:37
  • Hi ... that webpage is a whole portal used for different clients and it's out of my reach. But anyway, the problem seems to be this: http://stackoverflow.com/questions/10933207/how-to-fixmiss-a-drag-as-we-are-waiting-for-webcores-response-for-touch-down and http://code.google.com/p/android/issues/detail?id=4549 Basically, the whole portal area starts to move, which seems to be standard browser behaviour. Someone is already looking into the HTML, JS part solution, so I will see. – MartinC Jan 08 '13 at 13:01
  • Ok, sorted out on JS/HTML side. I consider this issue as resolved. – MartinC Jan 11 '13 at 08:20
  • how did you solve with js? would you kindly share your solution? – coder Jun 26 '16 at 09:53