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.
Asked
Active
Viewed 1,642 times
7
-
http://stackoverflow.com/a/4075955/1318946 – Pratik Butani Jul 20 '15 at 10:37
-
The webpage is from a third party so cant do anything on it. @PratikButani – Gaurav Jul 20 '15 at 10:43
-
The webpage is yours, but webview is not. So I wondering if calling `webView.requestFocus(View.FOCUS_DOWN);` will be of any help. As it will call focus to your webview only. – Darpan Jul 27 '15 at 03:26
-
I tried that. It doesnt help. And webview mine. Webpage is not. – Gaurav Jul 27 '15 at 09:49
-
you want to setup focus on navigation buttons? – Sergey Shustikov Jul 27 '15 at 10:22
-
@ssh There are 2 buttons which are inside a section in the webview. the focus comes on the entire section but doesnt go a level deeper on the buttons – Gaurav Jul 29 '15 at 13:39
-
1@Gaurav Did you found any solution? – Sanju Baghla Nov 15 '18 at 10:27
2 Answers
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