【问题标题】:Android - webview cuts offAndroid - webview 切断
【发布时间】:2023-03-29 12:37:01
【问题描述】:

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

图片:

代码:

    // 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>

【问题讨论】:

    标签: android webview webpage android-webview


    【解决方案1】:

    这里有两种可能性:

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

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

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

    【讨论】:

      【解决方案2】:

      从您的图片看来,您也在使用标签。这可能是由于嵌入式 webview 不知道其父级边界并采用屏幕宽度而不是选项卡视图的结果。

      您可以通过多种方式解决此问题,但可能最快/最脏的方法是弄乱 webview 的边距以匹配选项卡布局的边距。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-11
        • 1970-01-01
        相关资源
        最近更新 更多