zoukankan      html  css  js  c++  java
  • android 解决ScrollView中的子布局不能够填充整个ScrollView的情况。

    在开发中如果你的xml文件的跟布局是ScrollView,在ScrollView中无论你写什么样的布局,其默认情况下都是不能填充整个布局的。也就是说你的ScrollView中的子布局设置fill_parent不起作用。

    解决办法:

              在ScrolllView控件中加上android:fillViewport="true"则问题解决。

    官方文档的解释:

    Indicates this ScrollView whether it should stretch its content height to fill the viewport or not.
    表明这ScrollView是否应该延伸其内容高度来填补视窗。

    下面是网上的一段解释:

    ScrollView里只放一个元素.
      
      当ScrollView里的元素想填满ScrollView时,使用"fill_parent"是不管用的,必需为ScrollView设置:android:fillViewport="true"。
      
       当ScrollView没有fillVeewport=“true”时, 里面的元素(比如LinearLayout)会按照wrap_content来计算(不论它是否设了"fill_parent"),而如果LinearLayout的元素设置了fill_parent,那么也是不管用的,因为LinearLayout依赖里面的元素,而里面的元素又依赖LinearLayout,这样自相矛盾.所以里面元素设置了fill_parent,也会当做wrap_content来计算.
  • 相关阅读:
    python timeit模块用法
    boto3库限速
    golang-Beego-orm创建的坑
    Java07
    Java06
    Java04
    Java03
    c
    Mac 安装GCC
    命令: go build
  • 原文地址:https://www.cnblogs.com/tony-yang-flutter/p/3740902.html
Copyright © 2011-2022 走看看