• 在ScrollView下加入的组件,不能自动扩展到屏幕高度


    ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法

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

     1 例子,在ScrollView下加入的组件,无论如何也不能自动扩展到屏幕高度。
     2 
     3 布局文件。
     4 
     5 [html] 
     6 <?xml version="1.0" encoding="utf-8"?> 
     7 <!-- 背景:蓝色 --> 
     8 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     9     android:id="@+id/scrollView1" 
    10     android:layout_width="fill_parent" 
    11     android:layout_height="fill_parent" 
    12     android:background="#0000ff" > 
    13  
    14     <!-- 背景:绿色 --> 
    15  
    16     <LinearLayout 
    17         android:id="@+id/linearLayout1" 
    18         android:layout_width="fill_parent" 
    19         android:layout_height="fill_parent" 
    20         android:background="#00ff00" > 
    21  
    22         <TextView 
    23             android:id="@+id/textView1" 
    24             android:layout_width="wrap_content" 
    25             android:layout_height="fill_parent" 
    26             android:layout_weight="1" 
    27             android:text="Hello Android." > 
    28         </TextView> 
    29     </LinearLayout> 
    30  
    31 </ScrollView> 

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


    解决办法。

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

    但如果scrollview里放个listview不行

  • 相关阅读:
    大端小端与数字的二进制存储
    java基础之进制转换汇总
    (转) tcp udp通讯协议
    JAVA Tcp Udp的通讯实现(转)
    ExecutorService创建线程使用 转()
    转:java中的位运算
    SVN服务器的搭建与TortoiseSVN的使用
    [Mark]VM Cone & Template
    [Mark]VM migrate
    [Mark] ethtool command in REHL OS
  • 原文地址:https://www.cnblogs.com/CharlesGrant/p/4727799.html
Copyright © 2020-2023  润新知