简体   繁体   English

Android WebView固定元素不响应点击

[英]Android WebView fixed element doesn't respond to click

In my Android Webview I load my webpages. 在我的Android Webview中,我加载了网页。 These pages has Adsense in different parts of page. 这些页面在页面的不同部分具有Adsense。 If Adsense exists inside page, click event opens Adsense link in default browser/or asks to open where. 如果页面内部存在Adsense,则单击事件会在默认浏览器中打开Adsense链接/或要求在何处打开。 That's good. 那很好。

Problem is: 问题是:
- If adsense exists fixed in page (like: style="position: fixed;" , it can't be clicked. I click to Adsense in portarit and nothing happens. This is problem. -如果adsense存在页面中固定的内容(例如: style="position: fixed;" ,则无法单击它。我在portarit中单击Adsense并没有任何反应。这是问题。
- Adsense is in front of the page. -Adsense位于页面的前面。 So if there exists a link behind the Adsense image, when I click adsense, them bottom link is opened. 因此,如果Adsense图片后面有一个链接,则当我单击adsense时,将打开它们的底部链接。 - If I rotate device to landscape Adsense can be clickable, clicking opens new browser. -如果将设备旋转到横向,Adsense可以单击,则单击将打开新的浏览器。
- I added this z-index:9999; -我添加了这个z-index:9999; to adsense div. 到adsense div。 But behaviour is the same. 但是行为是一样的。 Doesn't respond to click. 不响应点击。

Also, I have a fixed top navbar (Twitter-bootstrap). 另外,我有一个固定的顶部导航栏(Twitter-bootstrap)。 When user scrolls down, if there exists a link behind the fixed navbar, if user clicks on navbar, webview opens the link behind the navbar. 当用户向下滚动时,如果在固定导航栏后面有一个链接,如果用户单击导航栏,则webview将打开导航栏后面的链接。

So as far as I see, links in the background has much priority then fixed element's links. 因此,据我所知,后台的链接比固定元素的链接具有更高的优先级。 And some of the fixed elements can't be clicked in portarit ? 并且某些固定元素无法在portarit中单击?

This problem occurs in Android 2.3.x. 在Android 2.3.x中会发生此问题。 I don't get problem in Android 4.x 我在Android 4.x中没有问题

我不确定是否可行,请尝试以下操作:

webView1.requestFocus(View.FOCUS_DOWN);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM