Android的中心和调整的WebView形象 [英] Android center and adjust image in webview
问题描述
我一直工作在最近编程的基本应用程序的webcomic并一直与web视图是如何显示的漫画的问题。图像本身加载细,但是总有多余的空白的上方或向图像的一侧,与图象总是被定位在网页视图的左上角。另外,通常的web视图被放大到所述图像一定程度,这是一个问题,因为在漫画中的尺寸变化
我想有图象负荷,以便它为中心,根据高度或宽度(取适当)调整,以使整个图像是可见的,并且如果可能的话消除空白。不幸的是,我不能因为任何原因没有模拟器可以运行应用程序提供问题的任何截图。
至于code去我刚才以下内容:
<的WebView
机器人:ID =@ + ID / webView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =300dp
机器人:layout_below =@ + ID / textView1
机器人:layout_gravity =中心
机器人:layout_centerHorizontal =真/>
在我的类code是这样用的图像是包含这是我从页面的HTML拉到图像URL字符串:
的WebView myWebView =(的WebView)findViewById(R.id.webView1);
myWebView.loadUrl(图片);
尝试设置了的android:layout_height =WRAP_CONTENT
和有关的空白问题,请尝试寻找到<一个href=\"http://stackoverflow.com/questions/9476151/webview-flashing-with-white-background-if-hardware-acceleration-is-enabled-an\">This链接
I've been working on programming a basic webcomic app lately and have been having issues with how webview is displaying the comics. The images themselves load fine, however there is always excess whitespace above or to the side of the image, with the image always being positioned at the top left corner of the webview. Also, typically the webview is zoomed into the image a certain degree, which is a problem as the comics vary in dimensions.
I would like to have the image load so that it is centered, adjusted based on height or width (whichever is appropriate) so that the entire image is visible, and if possible eliminate the whitespace. Unfortunately I cannot provide any screenshots of the problem because for whatever reason none of the emulators can run the app.
As far as code goes I have just the following:
<WebView
android:id="@+id/webView1"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_below="@+id/textView1"
android:layout_gravity="center"
android:layout_centerHorizontal="true" />
In the class my code is as such with image being a string that contains the image URL which I pulled from the page's HTML:
WebView myWebView = (WebView) findViewById(R.id.webView1);
myWebView.loadUrl(image);
Try setting the android:layout_height="wrap_content"
and about the whitespace issue, try looking into This Link
这篇关于Android的中心和调整的WebView形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!