2013-11-22 172 views
0

我製作了一個WebView,出於某種原因,邊框不能填滿整個屏幕。Android WebView寬度和高度

<WebView 
     android:id="@+id/webview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" /> 

有什麼建議嗎?

+0

所以你要在全屏的WebView? –

+0

是的,當我查看網站時,我正在查看的內容與實際的手機之間有一個體面的差距,如果這有意義嗎? – Paldan

回答

1

您可能會在Webview上方顯示佈局,如Linear,Relative ..等等。從佈局中刪除所有的屬性,如:

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 

試試這個:

<RelativeLayout 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" 
tools:context=".MainActivity" > 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

希望這有助於。

0

我相信你想給webview的邊框,它應該填滿整個屏幕。嘗試這樣的事情。

<LinearLayout 
      android:id="@+id/ll_webview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"    
      android:background="@color/blue_line" 
      > 

      <WebView 
       android:id="@+id/webview" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_margin="5dp" 
       android:scrollbars="none" /> 
0

在你的XML佈局試試這個:

<RelativeLayout 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"> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="5dp"/> 

</RelativeLayout>