Incorrect width in Android webkit browser

后端 未结 3 1987
清酒与你
清酒与你 2020-12-31 13:17

I noticed a problem on Android\'s default browser, where 100% width may actually go past the edge of the screen. Here\'s a minimal test case:

  
相关标签:
3条回答
  • 2020-12-31 13:36

    In my WebView, I was able to fix the widths by turning off wide viewport.

    webview.getSettings().setUseWideViewPort(false);
    

    This disables horizontal scroll unless absolutely necessary, and div widths and zoom work as expected. Obviously this will only work with a custom WebView, maybe there is a more generic way to do this with something like <meta name="viewport" ...> ?

    0 讨论(0)
  • 2020-12-31 13:39

    use

    layout_width="fillparent"
    

    :)

    0 讨论(0)
  • 2020-12-31 13:40

    Just add this meta tag inside your html head tag .I've checked it with android 2.1 browser and it works fine on zoom.

    <meta name="viewport" content="width=device-width" />
    
    0 讨论(0)
提交回复
热议问题