网页视图未显示在安卓布局中的按钮下方



在我使用按钮和Web视图实现线性布局之前,我的独立Web视图工作正常。 我添加了以下内容,现在只显示按钮:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="match_parent">
    <ImageButton
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/back_nav"
     />
    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</LinearLayout>

我只想要一个跨越顶部的按钮,在其下方有一个 Web 视图,填充视图的其余部分。

我做错了什么?

您的方向设置为水平,按钮设置为"fill_parent",这意味着 Web 视图将出现在按钮的右侧,该按钮将填满整个屏幕,使 Web 视图显示在屏幕之外。

要解决此问题,请将 LinearLayout 的方向设置为"垂直"。

最新更新