大马资讯论坛 - 马来西亚中文资讯平台

 找回密码
 注册
搜索
打印 上一主题 下一主题

[解決] Android 图片在WebView显示太宽了,超出荧幕,好难看

[复制链接]
跳转到指定楼层
1#
发表于 2014-4-13 15:36:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Android's WebView automatically resize huge images
Android WebView, Scaling Image to fit the screen
android - Fit image in webview

1. Add css below in your page 在你的网页加入以下css
  1. <style>
  2. img
  3. {
  4. width:100%;
  5. max-width:100%;
  6. }
  7. </style>
复制代码
2. Go to your android WebView setLayoutAlgorithm 设置你的Webview
  1. WebView oTextView = (WebView) oCurrentActivity.findViewById(R.id.oTextView );
  2. oTextView.getSettings().setDefaultTextEncodingName("UTF-8") ;
  3. oTextView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
  4. oTextView.getSettings().setSupportMultipleWindows(false);
  5. oTextView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
复制代码

手机版|大马资讯论坛  

GMT+8, 2024-5-2 22:57 , Processed in 0.012757 second(s), 12 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表