博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法
阅读量:6975 次
发布时间:2019-06-27

本文共 898 字,大约阅读时间需要 2 分钟。

例子,在ScrollView下加入的组件,无论如何也不能自动扩展到屏幕高度。

布局文件。

[] 

<?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 ." > 
        </TextView> 
    </LinearLayout> 
 
</ScrollView> 

效果图。

.

尽管已经设置了android:layout_height="fill_parent",但是,整个LinearLayout和TextView还是不能充满整个屏幕。

解决办法。

在ScrollView中添加一个android:fillViewport="true"属性就可以了。顾名思义,这个属性允许ScrollView中的去充满它。

修改后的效果图

(转自:http://www.2cto.com/kf/201208/148262.html)

转载地址:http://ncesl.baihongyu.com/

你可能感兴趣的文章
面面观 | CentOS install etcd 测试
查看>>
[CF566A]Matching Names
查看>>
[Oracle]ORA-01461: can bind a LONG value only for insert into a LONG column
查看>>
Linux学习之CentOS(三十三)--DNS基础及域名系统架构
查看>>
[复变函数]第03堂课 1.2 复平面上的点集
查看>>
Python:Opening Python Classes
查看>>
mvc:view-controller
查看>>
Android推送分析
查看>>
微信公众平台开发者文档
查看>>
ORACLE数据库不同故障下的恢复总结
查看>>
使用eclipse转换普通项目为web项目
查看>>
ASP.NET 5中的ASP.NET Bundles跑到哪里去了?
查看>>
云计算解码:技术架构和产业运营
查看>>
windows7学习一
查看>>
单选按钮易忽略的Group属性
查看>>
转 sql 优化
查看>>
PHP安全相关的配置(1)
查看>>
virtualbox 中,虚拟机网络使用NAT方式时,其它机器对虚拟机的访问
查看>>
Salesforce.com + AutoCAD WS集成研究 part2
查看>>
[Ubuntu] Access denied for user ‘debian-sys-maint’@'localhost’ (using password: YES)
查看>>