Android ScrollView只能添加一个子控件问题解决方法
本文实例讲述了Android ScrollView只能添加一个子控件问题解决方法。分享给大家供大家参考,具体如下:
有下面一段代码
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
一个ScrollView里面添加了三个Button,也许你认为没有什么问题,那么我们运行一下看看
出现了一个异常
很明显,异常告诉我们ScrollView can host only one direct child
既然说只能容纳一个直接的子控件,那么我们就可以容纳多个间接的子控件,直接在这些子控件外面再套一层LinearLayout就OK了
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
更多关于Android相关内容感兴趣的读者可查看本站专题:《Android开发入门与进阶教程》、《Android多媒体操作技巧汇总(音频,视频,录音等)》、《Android基本组件用法总结》、《Android视图View技巧总结》、《Android布局layout技巧总结》及《Android控件用法总结》
希望本文所述对大家Android程序设计有所帮助。相关阅读:
Oracle删除死锁进程的方法
javascript:void(0)是什么意思及href=#与href=javascriptvoid(0)的区别
实现DIV层内的文字垂直居中(单行文字/多行文字)
C#实现功能强大的中国农历日历操作类
jquery解析XML及获取XML节点名称的实现代码
Oracle数据库的启动与关闭方法
win7系统如何将浏览器版本调至较低版本 win7系统将浏览器版本调至较低版本的方法
Win7系统打不开Office2010文件的两种解决办法
JavaScript严格模式详解
android Textview文字监控(Textview使用方法)
php实现的微信红包算法分析(非官方)
C语言中读取时间日期的基本方法
Win10 Mobile正式版10586.107修复Bug:Windows Hello更好用
Fedora Linux系统配置Samba服务器