2016-10-28 2 views
1

나는 webview 애플 리케이션에서 일하고 있습니다, 내 문제는 오른쪽과 왼쪽에 여백이 있다는 것입니다 그리고 나는 그들을 제거하는 방법을 모르겠 초보자입니다. 참고 : 예 : 예 : 레이아웃에 해당하는 자바 상자의 전체 화면 콘텐츠에이 코드를 추가하십시오. 매니페스트 폴더오른쪽 및 왼쪽 안드로이드 webview 여백 제거

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="eizeasta.resale"> 
    <uses-permission android:name="android.permission.INTERNET" /> 



    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 

     <activity 
      android:name=".FullscreenActivity" 
      android:configChanges="orientation|keyboardHidden|screenSize" 
      android:label="@string/app_name" 
      android:theme="@style/FullscreenTheme"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

에서 1 레이아웃 - 전체 화면 활동 폴더

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.activity_fullscreen); 
     WebView view = (WebView) this.findViewById(R.id.webView); 
     view.setWebViewClient(new WebViewClient()); 
     view.loadUrl("http://google.com"); 

     view.getSettings().setJavaScriptEnabled(true); 

     mVisible = true; 
     mControlsView = findViewById(R.id.webView); 
     mContentView = findViewById(R.id.webView); 


     // Set up the user interaction to manually show or hide the system UI. 
     mContentView.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       toggle(); 
      } 
     }); 

     // Upon interacting with UI controls, delay any scheduled hide() 
     // operations to prevent the jarring behavior of controls going away 
     // while interacting with the UI. 

    } 



    @Override 
    protected void onPostCreate(Bundle savedInstanceState) { 
     super.onPostCreate(savedInstanceState); 

// Trigger the initial hide() shortly after the activity has been 
     // created, to briefly hint to the user that UI controls 
     // are available. 
     delayedHide(100); 


    } 

    private void toggle() { 
     if (mVisible) { 
      hide(); 
     } else { 
      show(); 
     } 
    } 

    private void hide() { 
     // Hide UI first 
     ActionBar actionBar = getSupportActionBar(); 
     if (actionBar != null) { 
      actionBar.hide(); 
     } 
     mControlsView.setVisibility(View.GONE); 
     mVisible = false; 

2 안드로이드 매니페스트 :

미리 감사, 여기에 코드입니다 java 폴더의 3- 액티비티 전 화면

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#0099cc" 
    tools:context="eizeasta.resale.FullscreenActivity"> 

    <!-- The primary full-screen view. This can be replaced with whatever view 
     is needed to present your content, e.g. VideoView, SurfaceView, 
     TextureView, etc. --> 

    <TextView 
     android:id="@+id/fullscreen_content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center" 
     android:keepScreenOn="true" 
     android:text="@string/dummy_content" 
     android:textColor="#33b5e5" 
     android:textSize="50sp" 
     android:textStyle="bold" /> 

    <!-- This FrameLayout insets its children based on system windows using 
     android:fitsSystemWindows. --> 

    <WebView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/webView" 
     android:layout_gravity="center" /> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <LinearLayout 
      android:id="@+id/fullscreen_content_controls" 
      style="?metaButtonBarStyle" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="bottom|center_horizontal" 
      android:background="@color/black_overlay" 
      android:orientation="horizontal" 
      tools:ignore="UselessParent"> 

     </LinearLayout> 

    </FrameLayout> 

</FrameLayout> 

답변

1

이 코드를 추가했는데 webview가 전체 화면에 적합하다는 문제점을 발견했습니다.

mWebView.getSettings().setUseWideViewPort(true); 
     mWebView.getSettings().setLoadWithOverviewMode(true); 
+0

열립니다 만약이의 코드를 적용한 후 answer, 당신의 HTML 내용이 너무 작아서 안락함을 원하지 않는다면,'mWebView.getSettings(). setTextZoom (percent)'를 사용하여 원하는 크기로 내용을 확대 할 수 있습니다 – ak93

0

언급 한 XML 파일 외에 다른 XML 파일이 있습니까? 부모 인 다른 레이아웃이있을 수 있습니다. 여백을 가진 부모 레이아웃은 무슨 일이 일어나는지 설명 할 수 있습니다.

+0

없음 xml 파일하지만 뭔가 이상한 해프닝이, 코드의 웹 사이트는 마진 열리지 만 내가 예를 들어 광고와 같은 다른 웹 사이트를 열 경우는 여백 –

관련 문제