ScrollView中子项设置match_parent失效,无法铺满全屏

2018-11-27 00:23:58

ScrollView中子控件设置match_parent失效,无法占满全屏


1、测试验证:


<ScrollView ....>

<LinearLayout ...>

..........

<LinearLayout

  android:layout_width="match_parent"

                android:layout_height="match_parent"

android:background="@color/cef">

.....

</LinearLayout>

</LinearLayout>

</ScrollView>



当我们设置背景颜色时,可以清楚的看到剩余空间并没有都设置为上面的背景色

2、 方法:


为ScrollView设置如下属性:


android:fillViewport="true"


引用一下别人的解释:



    当ScrollView没有fillVeewport=“true”时,里面的元素(比如LinearLayout)会按照wrap_content来计算(不论它是否设了"fill_parent"),而如果LinearLayout的元素设置了fill_parent,那么也是不管用的,因为LinearLayout依赖里面的元素,而里面的元素又依赖LinearLayout,这样自相矛盾.所以里面元素设置了fill_parent,也会当做wrap_content来计算.



  • 2021-04-25 09:53:18

    android debug速度特别慢有时候卡住

    一直提示定在 Starting LLDB server。可能的原因是 Android Studio编译速度太慢了,就会一直卡在Starting LLDB server。可以通过设置 Run/Debug Configurations ——> Debugger ——> Debug type 为 Java 跳过 C/C++的调试,起码实现对 Java 程序的调试

  • 2021-04-25 09:54:19

    sequelize 时区配置

    sequelize 默认情况下, 保存日期时会转换成 +00:00时区,