的WebView不灌装设备或模拟器的整个屏幕 [英] WebView is not filling the whole screen of device or emulator
问题描述
我开发一个Android应用程序启动时,加载Web应用程序。为了实现我使用的WebView控制的目的。我希望我的WebView以全屏显示,这样就会给本地的感觉给用户。我尝试了所有的方法来显示webthview全屏,但没有什么工作。我不知道我错过了什么。我需要的帮助。下面我发布,我试图还附上截图,显示了如何的WebView显示的是在模拟器和移动,以及在code片段。
I am developing an android application which loads a web application when started. To achieve the purpose I am using webview control. I want my webview to be displayed full screen so that it will give native feel to the users. I tried all the methods to display webthview full screen but nothing is working. I dont know what I am missing. I need help on that. Below I am posting the code snippets that I tried also attached screenshots that shows how webview is displaying on emulator and mobile as well.
方法1:尝试用简单的基本code
Method 1: Tried with simple basic code
webbrowser.setWebViewClient(new MyWebViewClient());
webbrowser.getSettings().setJavaScriptEnabled(true);
webbrowser.loadUrl("http://google.com");
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
方法2:尝试设置主题,清单文件全屏
Method 2: Tried setting theme as full screen in manifest file
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
方法3:尝试使用code就做
Method 3: Tried doing it using code
//Full screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
方法4:试图与ChromeClient
Method 4: Tried with ChromeClient
mWebView.setWebChromeClient(new MyWebChromeClient());
mWebView.addJavascriptInterface(new DemoJavaScriptInterface(), "demo");
mWebView.loadUrl("http://google.com/");
方法5:尝试过定义的WebView没有布局main.xml中
Method 5: Tried just defining webview without layout in main.xml
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview_compontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
/>
方法6:通过调整的WebView还试图用相对布局边缘父
Method 6: Also tried with relative layout by aligning webview edges to parent
没有为我工作。我用来测试的设备是三星Galaxy Tab和仿真的是Android 2.3.3。在7英寸的Galaxy Tab它显示了在中间,四面有空格。而在仿真器其留空间的底部。
Nothing worked for me. The device I am testing with is samsung galaxy tab and emulator is Android 2.3.3. In 7 inch galaxy tab it is showing up in the middle and on four sides there are blank spaces. Whereas in emulator its leaving space at the bottom.
我真的AP preciate如果有人可以指导我在此。
I really appreciate if someone can guide me on this.
推荐答案
只是广告中体现以下code:
just ad in manifest the following code:
>
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />
这篇关于的WebView不灌装设备或模拟器的整个屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!