Android WebView和按钮布局使按钮不可见

Android WebView和按钮布局使按钮不可见,android,layout,button,webview,Android,Layout,Button,Webview,我有以下布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android

我有以下布局:

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

    <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 xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal">

        <Button android:id="@+id/back"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="Back" />

        <Button android:id="@+id/page_number"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="1 / 100" />

        <Button android:id="@+id/next"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="Next" />
    </LinearLayout>
</LinearLayout>

其结果如下


如何使按钮适合屏幕并阻止WebView将其推出?

使用
RelativeLayout
。将RelativeLayout环绕按钮,如下所示:

   <RelativeLayout 
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true">
    <Button android:id="@+id/back"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="Back"
            android:layout_alignParentLeft="true"  />

    <Button android:id="@+id/page_number"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="1 / 100" />

    <Button android:id="@+id/next"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:text="Next" />
   </RelativeLayout>
编辑:


我遇到了完全相同的问题,只是我在我的WebView下面使用了一个TextView,在主WebView上面使用了第二个WebView,这都是我们聊天程序所必需的。TextView一直被WebView推下

我尝试了建议的切换到RelativeLayout,也尝试了TableLayout和嵌套LinearLayout,所有这些都达到了相同的效果。唯一有效的方法是固定WebView的像素大小[这引发了处理OnConfiguration()的棘手问题],或者搞乱布局权重。不过,布局权重也有类似的问题,因为网页的配置或大小发生了变化,周围的控件会被弄脏


看起来如果我想让它完全以一种方式工作,顶部的一个小webview、一个主webview和一个textview,我必须修复webview的像素大小,并在加载时(对于不同的屏幕)处理它们的大小更改,在屏幕旋转时处理onConfiguration change()。

现在它们完全消失了:p
android:layout_alignParentTop="true"`
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">
<RelativeLayout android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:layout_alignParentTop="true">

<WebView xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/webview"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
/>
</RelativeLayout>

<RelativeLayout android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"
              android:layout_alignParentBottom="true">

    <Button android:id="@+id/back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Back"
            android:layout_alignParentLeft="true" />

    <Button android:id="@+id/page_number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="1 / 100"
            android:layout_toRightOf="@+id/back" />

    <Button android:id="@+id/next"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Next"
            android:layout_toRightOf="@+id/page_number" />
 </RelativeLayout>
</RelativeLayout>