English 中文(简体)
a. 在网上浏览中树立形象
原标题:Put an image inside a webview and fit it width

I d like to use a WebView for displaying images potentially big (in order to seize it memory management). For the test i m loading this code in the WebView

<head></head>
<body>
    <img alt="test" src="file:///android_asset/cute-cat-sleeping.jpg">
</body>

问题是,如果我把它装上“象现在这样”的网页的话。 只有在图像的第一部分适合筛选时,才允许流放。 在这种例子中,图像高度完全出现在网上电文中,因此再也不允许:

“No

你们可以看到这种模式,使全球形象得到正确反映,尽管当形象被灌输,右上下角的行为是正确的,你可以在这里看到。

“correct

So I tried the (WebView).getSettings().setUseWideViewPort(true) and the result is that I can zoom out more than the image s width

“with

bottom行为在底线上是不正确的:

“zoom

Summarizing: I d like the max zoom out possible to be imageWidth=webview width and zoom behaviour like in the second image:

enter image description here

完整的和(或)有用的答案将放弃

EDIT:Bounty为Vinayak开放。 页: 1

最佳回答

Using Viewportetadata可帮助您完成这项工作。

The viewport is the area in which your web page is drawn. Although the viewport s visible area matches the size of the screen, the viewport has its own dimensions that determine the number of pixels available to a web page

审判

WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
问题回答

Load Html文档载于Webview中,把你的形象放在资产上,并用Html阅读该图像文档。

<htm>
  <table>
   <tr>
         <td>
           <img src="cat.gif" width="100%" alt="Hello">
         </td>
   </tr>
</table>
</html>

Now Load that Html file in Webview

webview.loadUrl("file:///android_asset/abc.html"); 

或者另一种方式

如果你使用线索,可以算出一个能够彩色或资源的背景参数。

因此,主编的xml文件载有网站概览。 页: 1

android:background="@+drawable/backgroundmain"

所用名称

   web.setBackgroundColor(0);

3. 使网站概览具有透明度,以了解背景形象。

这里的解决办法是,在超文本代码中设定成正比值等于100%,然后用<代码>上载荷:DataWithBaseURL(null, htnlString, “text/html”,“UTF-8”, 无效;方法。

try this code

String htnlString = "<!DOCTYPE html><html><body style = "text-align:center"><img src="http://shiaislamicbooks.com/books_snaps/UR335/1.jpg" alt="pageNo" width="100%"></body></html>";
yourWebView.loadDataWithBaseURL(null, htnlString, "text/html", "UTF-8", null);

Edit 阁下 网址:

WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签