zoukankan      html  css  js  c++  java
  • Android ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法

    例子,在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中的组件去充满它。


    修改后的效果图

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

  • 相关阅读:
    php设置和获取cookie
    字符截取 支持UTF8/GBK
    PHP自毁程序
    php短信发送
    PHP版QQ互联OAuth示例代码分享
    javascript中window.open()与window.location.href的区别
    SpringBoot文件上传
    IDEA或Webstorm设置Ctrl+滚轮调整字体大小
    IDEA和WebStorm破解教程--激活80年(ideaIU-2018.3.6以及之前的版本)
    3 字节的 UTF-8 序列的字节 2 无效
  • 原文地址:https://www.cnblogs.com/jenson138/p/4272086.html
Copyright © 2011-2022 走看看