Android - webview 中断

标签 android webview webpage android-webview

我目前有一个显示当前站点的 webview。但是,它会切断页面的一侧。见下图。有没有什么办法解决这一问题?也请参阅下面的代码和 xml。谢谢!

图片:

enter image description here

代码:

    // create alert dialog
    blogDialog = new AlertDialog.Builder(BlogActivity.this).create();

    // add progress bar support
    getWindow().requestFeature(Window.FEATURE_PROGRESS);

    // make progress bar visible
    getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
            Window.PROGRESS_VISIBILITY_ON);

    setContentView(R.layout.webtab);

    sdrWebView = (WebView) findViewById(R.id.sdrwebview);
    sdrWebView.getSettings().setJavaScriptEnabled(true);

    // set web view zoom
    //sdrWebView.setInitialScale(scaleInPercent)

    // set the width,zoom function, and other settings
    sdrWebView.getSettings().setUseWideViewPort(true);
    //sdrWebView.getSettings().getUseWideViewPort(true);
    sdrWebView.setInitialScale(0);
    sdrWebView.getSettings().setBuiltInZoomControls(false);
    sdrWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    sdrWebView.canGoBack();
    sdrWebView.getSettings().setAllowFileAccess(true);
    sdrWebView.getCertificate();

    // remove scrollbar
    sdrWebView.setVerticalScrollBarEnabled(false);

    // set the URL
    sdrWebView.loadUrl("http://www.stopdroprave.com");

    //enable flash
    sdrWebView.getSettings().setJavaScriptEnabled(true);

XML:

<RelativeLayout 
android:id="@+id/relativeLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical">
  <WebView
        android:id="@+id/sdrwebview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</RelativeLayout>

最佳答案

这里有两种可能性:

  1. 查看您的父 View (tabhost 布局)中是否有填充/边距。

  2. 将以下内容添加到您的:

<supports-screens android:smallScreens="true"
      android:normalScreens="true" 
      android:largeScreens="true"
  android:anyDensity="true" />

关于Android - webview 中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8012936/

相关文章:

android - BaseLayerAndroid 创建销毁日志消息

Javascript代码重定向到同一页面上的一个部门

javascript - 如何在我的网站中嵌入 ace 编辑器

java - 使用 AsyncTask.get() 和 onPostExecute() 的区别

android - 如何在android中修改我的自定义属性文件

java - 无法从我的 WebView 在 Whatsapp 上共享。获取 无法加载位于 Whatsapp://send?text= 的网页,因为 net::ERR_UNKNOWN_URL_SCHEME

python - Odoo 10 : Catch the UserError and show it to webpage

java - 使用媒体播放器或音池在 fragment 内的 onClick 中播放声音

java - 使用 SwipeRefreshLayout 从底部滚动到顶部不起作用

macos - Webview 不显示加载的内容