问题描述
巡航能力林小问题。
当我试图打开一个URL里面的WebView内容都没有显示出来。
如果我尝试这在我的电脑上它的工作。
Im haveing small problem.While i am trying to open a url inside webview the contents are not showing up.if i try this on my computer it does work.
在我的电脑,结果是这样的(对于模糊抱歉,但你仍然可以看到有一些文本。);
the result on my pc is like this(sorry for blurring, but you can still see that there are some text.) ;
然后我的设备
你可以看到有设备上只有一小部分的白色,但多数民众赞成它,注意多是加载在此之后。
as you can see there is only a small white part on the device but thats it, noting much is loading after this.
全code;
package com.example.[removed];
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
public class WebViewAct extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
WebView mYWeb = (WebView) findViewById(R.id.webView1);
mYWeb.getSettings().setJavaScriptEnabled(true);
mYWeb.getSettings().setBuiltInZoomControls(true);
mYWeb.getSettings().setSupportZoom(true);
mYWeb.getSettings().setLoadWithOverviewMode(true);
mYWeb.getSettings().setUseWideViewPort(true);
mYWeb.setScrollBarStyle(0);
mYWeb.setWebViewClient(new WebViewClient());
mYWeb.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mYWeb.loadUrl("http://IP/Filename.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.web_view, menu);
return true;
}
}
任何帮助将是巨大的!
PS:我发现,它显示了在Firefox和Chrome更糟糕的内容,但在铬,如果我那边,等维护为''请求桌面版网站,everhting作品般的魅力!'
所以如果可能的话我可以让web视图显示为桌面模式为默认?
any help will be great!PS: I found out that it shows the content in Firefox and Chrome even worse, but in chrome, if i swtich to ''Request desktop site everhting works like charm!''so if possible can i make webView show as Desktop mode as default?
编辑:
问题固定。
我加了 mYWeb.getSettings()setUserAgentString(UA);
,之后我与它内部下面的文本字符串:字符串UA = Mozilla的/ 5.0(X11; U; Linux的i686的; EN-US; rv中:1.9.0.4)的Gecko / 20100101火狐/ 4.0;
Problem fixed.I added mYWeb.getSettings().setUserAgentString(ua);
and after that i made a String with the following text inside of it: String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
和所有的工作之后完美!
我也许问这个quastion太快了,抱歉:)
and everything worked perfect after that!i maybe asked this quastion too fast, sorry :)
推荐答案
问题解决。我添加mYWeb.getSettings()setUserAgentString(UA);
,之后我与它内部下面的文本字符串:字符串UA = Mozilla的/ 5.0(X11; U; Linux的i686的; EN-US; rv中:1.9.0.4)的Gecko / 20100101火狐/ 4.0;
Problem fixed.I added mYWeb.getSettings().setUserAgentString(ua);
and after that i made a String with the following text inside of it: String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
和所有的工作之后完美!
我也许问这个quastion太快了,抱歉:)
and everything worked perfect after that!i maybe asked this quastion too fast, sorry :)
这篇关于网页视图无法正确显示的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!