上面部分放置WebView组件,下面部分放置按钮,我弄来弄去出现三种情况,一种是按钮悬浮在WebView上,一种是按钮不显示,一种是按钮和WebView连成整体了,只当WebView滚动到底部时才显示按钮我的目的是想在屏幕底部一直显示一些功能按钮,按钮上面的区域用WebView组件浏览网页,用xml文件实现,要求很简单的

解决方案 »

  1.   

    用RelativeLayout,android:alignParentBottom="true",你的按钮就会始终在底部
    WebView设置layout_above你的按钮和android:alignParentTop="true",就不会跟按钮重叠并且从顶部开始显示
      

  2.   


    <?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">
        <Button 
         android:id="@+id/btn"
         android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:layout_alignParentBottom="true"
        /> <ScrollView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_above="@id/btn"
      android:layout_alignParentTop="true">
        <WebView
    android:id="@+id/webview"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    />
    </ScrollView></RelativeLayout>
      

  3.   

    感谢li674688017老大指点,用了老大的代码后基本上有了效果了,只是有处请老大给改一下,一是当WebView中的内容不足的时候WebView控件并没有占据分给它的整个空间高度,而只占据可屏幕上面的一部分空间,剩下的地方空了露出黑底,很难看,能不能让WebView在任何时候都占满分给它的那块空间?二是下面如果并列放3个按钮的话代码怎么写?