Android的 - 网页视图切断 [英] Android - webview cuts off

查看:154
本文介绍了Android的 - 网页视图切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个的WebView 显示当前站点。然而,它切断页的一面。见下图。反正是有解决这一问题?请参阅下面我太code和XML。谢谢!

图:

code:

  //创建警报对话框
    blogDialog =新AlertDialog.Builder(BlogActivity.this).create();    //添加进度条支持
    。getWindow()requestFeature(Window.FEATURE_PROGRESS);    //使进度条可见
    getWindow()。setFeatureInt(Window.FEATURE_PROGRESS,
            Window.PROGRESS_VISIBILITY_ON);    的setContentView(R.layout.webtab);    sdrWeb​​View =(的WebView)findViewById(R.id.sdrwebview);
    sdrWeb​​View.getSettings()setJavaScriptEnabled(真)。    //设置Web视图缩放
    //sdrWeb​​View.setInitialScale(scaleInPercent)    //设置宽度,变焦功能和其他设置
    。sdrWeb​​View.getSettings()setUseWideViewPort(真);
    //sdrWeb​​View.getSettings().getUseWideViewPort(true);
    sdrWeb​​View.setInitialScale(0);
    。sdrWeb​​View.getSettings()setBuiltInZoomControls(假);
    。sdrWeb​​View.getSettings()setJavaScriptCanOpenWindowsAutomatically(真);
    sdrWeb​​View.canGoBack();
    。sdrWeb​​View.getSettings()setAllowFileAccess(真);
    sdrWeb​​View.getCertificate();    //删除滚动条
    sdrWeb​​View.setVerticalScrollBarEnabled(假);    //设置URL
    sdrWeb​​View.loadUrl(http://www.stopdroprave.com);    //启用闪光灯
    sdrWeb​​View.getSettings()setJavaScriptEnabled(真)。

XML:

 < RelativeLayout的
机器人:ID =@ + ID / relativeLayout1
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
的xmlns:广告=htt​​p://schemas.android.com/apk/lib/com.google.ads
机器人:方向=垂直>
  <的WebView
        机器人:ID =@ + ID / sdrwebview
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT/>
< / RelativeLayout的>


解决方案

下面两种可能性:


  1. 看,如果你在你的父视图(tabhost布局)得到填充/保证金。


  2. 添加下列内容:



 <支持屏安卓smallScreens =真
      机器人:normalScreens =真
      机器人:largeScreens =真
  机器人:anyDensity =真/>


I currently have a webview that displays a current site. However, it cuts off the side of the page. See the picture below. Is there anyway to fix this? See my code and xml below too. Thanks!

Picture:

Code:

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

解决方案

Two possibilities here:

  1. Look if you got padding/margin in your parent view (the tabhost layout).

  2. Add following to your:

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

这篇关于Android的 - 网页视图切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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