小编Cod*_*eek的帖子

错误:Android-XML:将<WebView>放置在使用wrap_content大小的父元素中可能会导致细微的错误; 使用match_parent

我是Android的初学者,linear layout在这样的布局XML文件中构建并获得错误,

错误

 Placing a <WebView> in a parent element that uses a wrap_content size can lead to subtle bugs; use match_parent
Run Code Online (Sandbox Code Playgroud)

错误显示在代码的这一部分中

<WebView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/browse"
        />
Run Code Online (Sandbox Code Playgroud)

这是我的XML文件的完整代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:weightSum="100" >

        <EditText
            android:id="@+id/url"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="70"
            android:ems="10" >
        </EditText>

        <Button
            android:id="@+id/go"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="30"
            android:text="GO" />
    </LinearLayout>

    <LinearLayout
         android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
         android:weightSum="8"

        >
    <Button
        android:id="@+id/backpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="Go Back" />

    <Button
        android:id="@+id/forwardpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

xml android android-linearlayout

10
推荐指数
3
解决办法
9043
查看次数

标签 统计

android ×1

android-linearlayout ×1

xml ×1