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来计算.



  • 2017-08-17 17:58:48

    /usr、/home、/bin、/dev、/var、/etc中主要存放什么文件

    /usr 最庞大的目录,要用到的应用程序和文件几乎都在这个目录。其中包含: /usr/X11R6 存放X window的目录 /usr/bin 众多的应用程序 /usr/sbin 超级用户的一些管理程序 /usr/doc linux文档 /usr/include linux下开发和编译应用程序所需要的头文件 /usr/lib 常用的动态链接库和软件包的配置文件 /usr/man 帮助文档 /usr/src 源代码,linux内核的源代码就放在/usr/src/linux里 /usr/local/bin 本地增加的命令 /usr/local/lib 本地增加的库

  • 2017-08-17 19:26:00

    mysql安装目录、配置文件存放位置

    linux系统下,如何知道mysql使用的配置文件到底是哪个呢?linux自带的mysql的安装目录又是什么呢?数据存放在什么目录下?