ScrollView内部元素如何做到fill_parent 或者 match_parent?
转 : http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0704/1629.html
ScrollView滚动视图是指当拥有很多内容,屏幕显示不完时,需要通过滚动跳来显示的视图。Scrollview的一般用法如下
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
>
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/first_edittext"
android:layout_width="fill_parent"
android:background="@color/gray"
android:layout_height="fill_parent"
android:text="文字"
/>
</LinearLayout>
</ScrollView>
得到下面的界面:

其中白色部分是scrollView,灰色部分是TextView,很明显,scrollview(白色)已经扩展到最大高度了,但是其内部的可明明TextView的TextView(灰色)却没有扩展.layout_height="fill_parent",为什么没占满呢?是因为TextView的上层LinearLayout为wrap_content的原因吗?
但是换成fill_parent还是一样的(实际上Scrollview的第一层View的layout_weight在sdk中是建议为wrap_content的)。
后来在stackoverflow上找到了原因: http://stackoverflow.com/questions/2599837/linearlayout-not-expanding-inside-a-scrollview
要让ScrollView内部元素的 fill_parent 起作用必须设置android:fillViewport="true"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
ScrollView内部元素如何做到fill_parent 或者 match_parent?的更多相关文章
- Android Scrollview 内部组件android:layout_height="fill_parent"无效的解决办法
Found the solution myself in the end. The problem was not with the LinearLayout, but with the Scrol ...
- Android ScrollView内部组件设置android:layout_height="fill_parent"无效的解决办法
问题:scrollview内部组件都设置了android:layout_height="fill_parent"却没有效果. 解决办法:设置scrollview的fillViewp ...
- CSharp程序员学Android开发---3.Android内部元素不填充BUG
最近公司组织项目组成员开发一个Android项目的Demo,之前没有人有Andoid方面的开发经验,都是开发C#的. 虽说项目要求并不是很高,但是对于没有这方面经验的人来说,第一步是最困难的. 项目历 ...
- JS/jquery获取iframe内部元素和ifame中获取外部元素精华
1.从外部获取iframe内部元素方法: js : window.frames['frame'].document.getElementById("imglist"); //f ...
- Canvas 内部元素添加事件处理
目录 前言 自定义事件 有序数组 元素父类 事件判断 其他 立即执行函数 apply, call, bind addEventListener 传参 调用父类的构造函数 对象检测 isPointInP ...
- 关于fill_parent,match_parent和wrap_content (转载)
fill_parent&match_parent: 在Android2.2及以上版本中,fill_parent与match_parent意思相同(其中fill_parent兼容低版本).都是尽 ...
- fill_parent 和 match_parent区别
之前一直没有区别好 fill_parent 和 match_parent, 其实,在 api 8 以后,两者的作用几乎一样,都是填充控件 在这里延伸到android 的版本变化导致方法的变化问题 我对 ...
- 【HTML5】Canvas 内部元素添加事件处理
前言 canvas 没有提供为其内部元素添加事件监听的方法,因此如果要使 canvas 内的元素能够响应事件,需要自己动手实现.实现方法也很简单,首先获得鼠标在 canvas 上的坐标,计算当前坐标在 ...
- div内部元素居中
要让div内部元素垂直居中,则给div加上此css样式: .div-vertical-middle{ height:200px; width:304px; line-height:50px; ...
随机推荐
- 2015 Selenium大会
9月8号到10号三天在俄勒冈州的波特兰召开了Selenium Conference 2015,分享的演讲很多,视频也放出来了,做了下搬运工,传到优酷 简介: A conference that bri ...
- ADO.Net属性扩展
属性扩展 大体意思:有外键关系时将代号化信息处理成原始文字 如:Info表中的民族列显示的是民族代号处理成Nation表中的民族名称 需要在Info类里面扩展一个显示nation名称的属性 using ...
- ADO.NET防止字符串攻击方法
在黑窗口里面输入内容时利用拼接语句可以对数据进行攻击 如:输入班级值 --:代表后边内容都被注释掉了 防止SQL注入攻击方法: 再给命令发送SQL语句的时候分两次发送,把SQL语句拆成两块,用户输入的 ...
- oracl中的集合操作符
1:union(并集) union连接两条sql语句,并且去除两条sql语句重复的记录 2.union all(并集) 接两句sql语句,两句sql语句的和不用去掉重复的记录. 3:inter ...
- Html中模态框(弹出框)使用入门
作为html学习学习模态框需要二步: 效果图 第一步学习HTML中 div的弹出 ①触发按钮 <input class="btn btn-success" i ...
- ExcelHelper
NPOI下载:http://pan.baidu.com/s/1JNAGm 最新封装类: 2016-03-14 1.添加对OleConn的读 private static string connstri ...
- jquery工具方法makeArray/merge
makeArray : 类数组转真数组 merge : 合并数组或转特殊json 使用例子(外部使用): var aDiv = document.getElementsByTagName('div') ...
- HTML DOM 事件
HTML DOM 事件 HTML DOM 事件 HTML DOM 事件允许Javascript在HTML文档元素中注册不同事件处理程序. 事件通常与函数结合使用,函数不会在事件发生前被执行! (如用户 ...
- HTTP下密码的安全传输、OAuth认证
在复杂的web环境下,我们没有百分的把握保证信息在传输的过程中不被接货,那不是用明文如何告诉服务器自己的身份呢? 在一些高度通信安全的网络中,数据传输会使用HTTPS作为传输协议,但是通常情况下我们没 ...
- 修改Esxi克隆的CentOS的IP地址
1.读取/etc/udev/rules.d/70-persistent-net.rules文件中eth1的MAC地址. 2.编辑文件 /etc/sysconfig/network-script/ifc ...