android LinearLayout布局子空间没有填充父控件的问题

来源:互联网 发布:语音广告播放软件 编辑:程序博客网 时间:2024/05/27 03:25

开发中遇到一个问题,子控件无法填充父控件,

...

<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >
                
                <include layout="@layout/view" />
                
</LinearLayout>

...

按照网上的说法:

外层LinearLayout的android:orientation属性如果没有设置的话

内部的控件即使设置了android:layout_width="fill_parent",仍然无法达到内部控件充满

所以只需将外层LinearLayout的android:android:orientation设置为vertical即可

也不起作用,后来将LinearLayout的android:layout_height="match_parent",改为android:layout_height="0dp"
同时设置权重为1 可以了,但是再运行一次又不行了

...

<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="vertical" >
                
                <include layout="@layout/view" />
                
</LinearLayout>

...

最后发现是背景图片的问题,背景图片使用的是9png,只画了top和left两条线,按说默认情况下,内容可以显示在整个区域,但是却只在缩放区显示内容,修改9png后问题解决,但是另外一个布局用的是相同的背景图片确可以正常显示,不知道具体原因是什么,或许和系统有关吧。

0 0
原创粉丝点击