所以我有一个网页视图我想显示作为对话。我想web视图填满整个屏幕,但它下面的按钮,我想留在对话框的底部,无论有多少内容是在网页视图。目前我的WebView填充对话框刚够按下按钮关闭屏幕。我敢肯定,这是一件很容易的,但对我的生活,我一直没能找到布局,观点和属性值的神奇组合,让它发挥好。只是要清楚,我已经得到了它,因此按钮浮在web视图,但我想要的WebView停止只是上面的按钮和滚动,如果是有道理的。

<RelativeLayout android:id="@+id/RelativeLayout01" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">
  <WebView android:id="@+id/webview"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content"
           /> 
  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentBottom="true"
          />
</RelativeLayout>
有帮助吗?

解决方案

您想使用Android:layout_above = “@ + ID / btnOk” 为您的WebView,并为web视图的宽度和高度做FILL_PARENT

不过,要注意的是,在1.5及以下,RelativeLayout的意见需要,以指定在XML换句话说,要正确认识..重要的是,你必须先有你的按钮,然后WebView中,因为web视图将引用的按钮。我认为这已在1.6或2.0被改变,但我不积极哪个。

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

  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"/>
    <WebView android:id="@+id/webview"
           android:layout_above="@+id/btnOk"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           /> 
</RelativeLayout>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top