Android 如何使webview适应全屏?

Android 如何使webview适应全屏?,android,webview,Android,Webview,我希望我的网络视图适合屏幕,现在网络视图上有一个小的空白边框(不是全屏)。如何使用xml代码使我的webview适合屏幕 用此代码替换您的WebView代码 <WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/webView" android:layout_alignParentLeft="true" an

我希望我的网络视图适合屏幕,现在网络视图上有一个小的空白边框(不是全屏)。如何使用xml代码使我的webview适合屏幕


用此代码替换您的WebView代码

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_margin="0dp"
    android:padding="0dp"/>


我认为这一代码更改对您有效

您只需在父布局中添加以下内容:

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

您遇到的问题很可能是因为您的activity\u main可能仍然具有在首次创建应用程序时放入的预设填充。这是我制作的一个代码示例,它在全屏上工作:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
ndroid:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity" >


在xml文件中,将活动填充更改为“0dp”
并将webview更改为“填充父对象”或“匹配父对象”。

我想您已经使用了fragment。所以尝试检查活动xml中的空白或边距。尝试使用布局_重量和高度匹配_webview的父项…同时放置您的主要活动。xml文件我也尝试过@SagarAgharayes…然后删除活动_主中的空白或边距,这将解决您的问题。@DheerubhaiBansalyes已经告诉您,100%的活动是空白活动\主16dp检查它。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
ndroid:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity" >