如何设置在中心的WebView内容? [英] How to set WebView Content in Center?

查看:129
本文介绍了如何设置在中心的WebView内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在加载某些网页视图HTML内容,但它总是在我的WebView的左上角来了。

我曾尝试使用样式表也,在样式表我加入中心相关产品关键词,但其在中心不来了。其他标签的样式表工作正常。

如何设置的WebView内容垂直和水平中心?

我的HTML code

 < HTML和GT;< HEAD> <风格类型= \\文/ CSS \\> @字体面{FONT-FAMILY:MyCustomFont; SRC:URL(\\文件:///android_asset/fonts/MyriadPro-Regular.otf \\)} {身体FONT-FAMILY:MyCustomFont;字体大小:14;文本对齐:中心;垂直对齐:中间;线高度:正常;}< /风格> < /头><身体GT;的Hello World< /身体GT;< / HTML>


解决方案

试试这个:

 < HTML和GT;
< HEAD>
  <风格类型=文/ CSS>
@字体面{FONT-FAMILY:MyCustomFont;
SRC:URL(〜/ android_asset /字体/ MyriadPro-Regular.otf)}
#text {FONT-FAMILY:MyCustomFont;
字体大小:14;
文本对齐:中心;
保证金:350像素;
行高:正常;
颜色:蓝色;
高度:20像素;
宽度:100像素;
保证金:汽车;
背景色:红色;
}
< /风格>
< /头>
<身体GT;
< p n =文本>的Hello World< / P>
 < /身体GT;
< / HTML>

我认为,你的地址源字体是错误的!

I am loading some HTML content in WebView but its always coming in the top left corner of my WebView.

I have tried to use stylesheet also, in stylesheet I have added center related tages but its not coming in center. others tags in stylesheet works fine.

How to set content in WebView vertically and horizontally center ?

my HTML Code

<html><head>  <style type=\"text/css\"> @font-face { font-family: MyCustomFont;  src:url(\"file:///android_asset/fonts/MyriadPro-Regular.otf\") } body { font-family: MyCustomFont; font-size:14; text-align: center;vertical-align:middle;line-height: normal;} </style> </head><body> Hello World </body></html>

解决方案

try this:

<html>
<head>
  <style type="text/css"> 
@font-face { font-family: MyCustomFont;  
src:url("~/android_asset/fonts/MyriadPro-Regular.otf") } 
#text{ font-family: MyCustomFont; 
font-size:14; 
text-align: center;
margin:350px;
line-height: normal;
color:blue;
height:20px;
width:100px;
margin:auto;
background-color:red;
} 
</style> 
</head>
<body>
<p id="text"> Hello World</p>
 </body>
</html>  

And I think that your address source font is mistake!

这篇关于如何设置在中心的WebView内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆