Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 加载URL后WebView上的重力_Android_Layout_Android Layout_Webview_Android Webview - Fatal编程技术网

Android 加载URL后WebView上的重力

Android 加载URL后WebView上的重力,android,layout,android-layout,webview,android-webview,Android,Layout,Android Layout,Webview,Android Webview,您好,我有一个类似上面定义的WebView: <LinearLayout android:id="@+id/linearLayout4" android:layout_width="0dp" android:layout_height="match_parent" android:orientation="vertical" android:layout_weight="25" >

您好,我有一个类似上面定义的WebView:

    <LinearLayout
        android:id="@+id/linearLayout4"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="25" >

        <WebView
            android:id="@+id/home_banner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_margin="10dp" />

    </LinearLayout>

当WebView加载横幅时,它会丢失重力属性,将其放置在LinearLAyout的左侧,从而在右侧创建大量空白

有没有办法解决这个问题?非常感谢

试试这个
Try this    

    <WebView
        android:id="@+id/home_banner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp" />

您到底想要什么?你想把网络视图放在布局的中心吗?+Pramod,是的,这正是我想要的。但是当我加载URL时,网络视图并没有水平居中。这是你的完整布局吗?+Pramod,这是布局的一部分。没有必要显示整个布局。