Android 技术总结(004)—— ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
来源:互联网 发布:苹果电脑做淘宝方便吗 编辑:程序博客网 时间:2024/05/22 03:19
例子,在ScrollView下加入的组件,无论如何也不能自动扩展到屏幕高度。
布局文件。
[html]
<?xml version="1.0" encoding="utf-8"?>
<!-- 背景:蓝色 -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#0000ff" >
<!-- 背景:绿色 -->
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Hello Android." >
</TextView>
</LinearLayout>
</ScrollView>
效果图。
尽管已经设置了android:layout_height="fill_parent",但是,整个LinearLayout和TextView还是不能充满整个屏幕。
解决办法。
在ScrollView中添加一个android:fillViewport="true"属性就可以了。顾名思义,这个属性允许ScrollView中的组件去充满它。
修改后的效果图。
作者:manoel
from:http://www.2cto.com/kf/201208/148262.html
- Android 技术总结(004)—— ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件 android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法 .
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- android中关于scrollview内部组件android:layout_height="fill_parent"无效的解决办法
- Android Scrollview 内部组件android:layout_height="match_parent"无效的解决办法
- 解决scrollView中设置组件fill_parent不起作用
- Android Layout的layout_height等属性为什么有时会不起作用?
- ScrollView嵌套LinearLayout设置android:layout_height="match_parent"没效果解决
- 在Scrollview中布局中设置android:layout_height="match_parent"无效
- android ScrollView 中子控件设置高度后不起作用的解决方法
- android ScrollView 中子控件设置高度后不起作用的解决方法
- android ScrollView 中子控件设置高度后不起作用的解决方法
- [Android Studio 权威教程]配置出“NB”的Android Studio
- 批处理定时自动更新SVN
- 计蒜客 第9题:元素移除
- Spark入门实战系列--3.Spark编程模型(上)--编程模型及SparkShell实战
- 数据存储
- Android 技术总结(004)—— ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
- VS下如何实现一个工程具有两个项目, 测试项目B 调用 A项目生成的dll文件
- PWM波(存在问题,待解决)
- java.lang.UnsupportedOperationException
- javascript 原生 模仿 jquery 选择器 代码
- Linux工具使用
- 将txt文件批量转换成pdf格式的方法
- Java 实现导出excel表 POI
- 使用代码和storyboard分别创建UITabBarController