安卓设备或电视设备加载html文件后,显示不全

福尔摩斯对我笑 2019-05-14 35980 次 3411条

最近项目中使用安卓的webview控件将html文件加载到电视和win的设备上,经过测试,发现在一张1920*1080的html文件,在win上可以正常显示,在电视屏幕上显示不全

问题排查

  • 安卓是否设置为自动适应屏幕,是否支持缩放,然而设置后发现还是不正常,继续
//适应屏幕
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);


webView.setVisibility(View.VISIBLE);
webView.setBackgroundColor(0);
webView.getSettings().setAllowFileAccess(true);// 设置允许访问文件数据webView.getSettings().setSupportZoom(true);//支持放大网页功能webView.getSettings().setBuiltInZoomControls(true);//支持缩小网页功能


  • 查看html页面中是否设置meta标签,经查证设置了该标签,并支持缩放,然而还是不行

<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />

  • 后来去掉了meta标签后,竟然正常了,所有设备测试通过.

原因如下:meta viewport 标签之前,layout viewport 宽度是浏览器默认的(大部分浏览器、WebView都默认为这个值)。meta viewport 标签之后,因为指定了 initial-scale=1,所以浏览器将 layout viewport 宽度设为 visual viewport(可视区域) 的宽度,其它一系列的 width 也跟风进行变动。

https://landchanning.github.io/2018/01/25/webview_viewport/

具体关于viewport的说明请查看 https://www.cnblogs.com/2050/p/3877280.html

标签: 无

非特殊说明,本博所有文章均为博主原创。

头像也是LOGO
未来博客 博主大人
到了这个年纪,不应该再彷徨!

发表评论



 


已有 3411 条评论 1


  1. christian louboutin shoes

    Thank you so much for giving everyone a very special possiblity to read critical reviews from here. It is always so pleasing and as well , full of amusement for me personally and my office fellow workers to search the blog really three times every week to study the latest secrets you have got. And definitely, I’m just at all times astounded with the spectacular tricks you give. Certain 1 points in this post are ultimately the most impressive I have ever had.

    回复 2019年10月17日
  2. kobe shoes

    I actually wanted to type a quick comment so as to express gratitude to you for all the fabulous ways you are posting here. My particularly long internet investigation has now been rewarded with reasonable information to exchange with my contacts. I ‘d repeat that many of us readers actually are really lucky to live in a decent website with so many brilliant people with insightful plans. I feel somewhat fortunate to have seen the web page and look forward to some more fun minutes reading here. Thanks a lot once again for everything.

    回复 2019年10月16日
  3. jordan shoes

    Thank you for all of your labor on this web site. My mother really likes carrying out investigation and it’s easy to see why. A number of us know all concerning the powerful tactic you create great strategies through this web site and as well increase contribution from other individuals on this content while our child is truly being taught so much. Enjoy the rest of the new year. You have been performing a superb job.

    回复 2019年10月15日
  4. golden goose outlet

    I intended to post you this little observation to finally thank you very much as before just for the remarkable knowledge you’ve documented on this page. This has been certainly remarkably generous with people like you to supply easily what a lot of people might have made available as an e-book to make some cash for themselves, principally considering that you might have tried it if you desired. The thoughts additionally acted as the great way to fully grasp that other people have the same fervor the same as my very own to find out much more in regard to this problem. I know there are some more enjoyable sessions up front for people who read your blog.

    回复 2019年10月14日
  5. nike air max 90

    My wife and i ended up being so thankful when Raymond could finish up his survey through your ideas he had out of the site. It’s not at all simplistic to simply choose to be releasing tips and tricks many others could have been making money from. Therefore we already know we have got you to thank for this. The specific illustrations you have made, the straightforward blog navigation, the relationships you can make it possible to promote – it’s got mostly powerful, and it’s really leading our son and the family know that this theme is satisfying, which is tremendously important. Many thanks for all the pieces!

    回复 2019年10月13日
  6. supreme clothing

    I precisely wanted to appreciate you all over again. I do not know the things that I might have gone through without the entire basics revealed by you concerning this subject. It actually was a real frightening case in my opinion, however , taking note of the specialised approach you treated it made me to jump with happiness. I’m happy for this work and expect you recognize what a powerful job you were undertaking instructing people today by way of your web site. I’m certain you haven’t encountered any of us.

    回复 2019年10月12日
  7. cheap jordans

    I precisely wished to appreciate you yet again. I’m not certain the things I could possibly have sorted out without the type of secrets provided by you on such theme. It became a depressing situation in my position, nevertheless coming across this professional tactic you treated the issue forced me to cry over delight. Extremely thankful for the support as well as have high hopes you are aware of an amazing job you’re accomplishing training the others with the aid of your webpage. Most probably you have never come across all of us.

    回复 2019年10月12日
  8. golden goose sneakers

    My wife and i felt now lucky that Albert could complete his investigations from your precious recommendations he discovered through your web page. It’s not at all simplistic just to always be freely giving guidelines which often the others may have been making money from. And we also realize we have got you to thank because of that. The specific explanations you made, the simple web site navigation, the friendships you will give support to create – it is mostly powerful, and it is assisting our son and our family do think this article is enjoyable, which is certainly rather essential. Thanks for all the pieces!

    回复 2019年10月11日
  9. air max 270

    I as well as my pals came studying the nice techniques on your web blog then instantly I got a horrible feeling I never thanked the site owner for those tips. All the men came totally passionate to see all of them and have now in truth been tapping into them. Appreciation for turning out to be quite helpful and then for obtaining varieties of fabulous guides most people are really eager to know about. Our own sincere apologies for not expressing appreciation to earlier.

    回复 2019年10月10日
  10. bape hoodie

    I wanted to send you one bit of word to be able to say thanks a lot as before for your lovely ideas you’ve contributed on this page. It was so seriously open-handed with you to offer unhampered what most of us would have offered as an e book to generate some bucks for their own end, particularly considering that you could have tried it if you decided. Those thoughts in addition served to provide a great way to be sure that many people have the identical dream just as my very own to realize significantly more with respect to this problem. I’m certain there are several more fun periods ahead for folks who read through your website.

    回复 2019年10月9日
  11. nike air vapormax

    I as well as my friends have already been analyzing the best advice located on your web site and then the sudden came up with a horrible feeling I never expressed respect to the blog owner for those tips. Those boys were definitely consequently warmed to see them and now have in reality been making the most of these things. I appreciate you for turning out to be quite considerate and also for deciding upon this kind of awesome topics millions of individuals are really eager to be informed on. My personal honest regret for not saying thanks to earlier.

    回复 2019年10月8日