Android的布局实在是让俺太郁闷了,怎么实现把屏幕分成上下两部分 上面部分放置WebView组件,下面部分放置按钮,我弄来弄去出现三种情况,一种是按钮悬浮在WebView上,一种是按钮不显示,一种是按钮和WebView连成整体了,只当WebView滚动到底部时才显示按钮我的目的是想在屏幕底部一直显示一些功能按钮,按钮上面的区域用WebView组件浏览网页,用xml文件实现,要求很简单的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用RelativeLayout,android:alignParentBottom="true",你的按钮就会始终在底部WebView设置layout_above你的按钮和android: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"> <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> 感谢li674688017老大指点,用了老大的代码后基本上有了效果了,只是有处请老大给改一下,一是当WebView中的内容不足的时候WebView控件并没有占据分给它的整个空间高度,而只占据可屏幕上面的一部分空间,剩下的地方空了露出黑底,很难看,能不能让WebView在任何时候都占满分给它的那块空间?二是下面如果并列放3个按钮的话代码怎么写? 请问一个启动第三方应用程序的问题 实在是想不通啊! 关于sqlite数据库的纠结问题,新手请教 请高手看一下 android文件读取问题~ android 分享功能中如何去除不必要的分享程序 如360助手这些等等 home键 dialig弹出问题 咨询SQLite数据库的几个问题 android大神求救,关于底部弹出菜单的问题 android设备上开启热点,其他手机连热点要做认证才能上网 由bitmap转为drawable的时候,图片缩小了????奇迹? appwidget开机后自动添加到Home Screen
WebView设置layout_above你的按钮和android: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">
<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>