7

I have a android TV app and so all my controls are using the focus(remote). I have a webview which loads up the url and displays the content. Now this page has a section in the centre and there are 2 buttons inside this section. Now the focus is on the section itself and it doesnt go inside and focus on the buttons. If I click on up and down buttons on the remote, the page just scrolls up and down but the focus doesnt move inside to the buttons. Any idea how I can solve this? Thanks.

Gopal Singh Sirvi
  • 4,539
  • 5
  • 33
  • 55
Gaurav
  • 1,700
  • 4
  • 22
  • 38

2 Answers2

0

Hi you can try something like this

mWebview.setOnTouchListener(new View.OnTouchListener() { 
    @Override
    public boolean onTouch(View view, MotionEvent event) {
        switch (event.getAction()) { 
            case MotionEvent.ACTION_DOWN: 
            case MotionEvent.ACTION_UP: 
                if (view.hasFocus() == false) { 
                    view.requestFocus(); 
                } 
                break; 
         } 
         return false; 
    }
});
br00
  • 1,391
  • 11
  • 21
0

I think you need a wrapper on your webview, which holds navigation above on webview.

After that disable all user-actions to this webview.(touch,focus,etc..)

Setup buttons and redirect user actions to webview.

For ex.

UP button click -> redirect to scroll webview.

Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119