android LinearLayout布局子空间没有填充父控件的问题
2014-04-02 10:39
561 查看
开发中遇到一个问题,子控件无法填充父控件,
...
<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后问题解决,但是另外一个布局用的是相同的背景图片确可以正常显示,不知道具体原因是什么,或许和系统有关吧。
...
<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后问题解决,但是另外一个布局用的是相同的背景图片确可以正常显示,不知道具体原因是什么,或许和系统有关吧。
相关文章推荐
- 【InstanceState】Android开发之InstanceState详解
- Android横竖屏总结(转)
- android.os.NetworkOnMainThreadException fixed
- Android背景问题
- 【豌豆荚 & 360助手】发布第一个私人项目
- Android-Universal-Image-Loader异步加载图片框架学习研究
- android listview 使用checkbox问题
- Android 中 shape 图形的使用
- 深入理解Android Wi-Fi,NFC和GPS卷 全面到货
- Android开发必备库
- android 官方文档人机交互指南在线翻译
- android 编程中"<<"是什么意思?有什么作用?
- android屏幕适配
- Android中的Bmp图形格式(ALPHA_8,ARGB_4444,ARGB_8888,RGB_565)
- 教你如何用Android画一个几何图形
- Android 学习笔记(十一):9妹(NinePatch )
- 谈谈android模拟器和真机的差别
- Android模拟器(AVD)上不了网(转)
- Android应用如何开机自启动、自启动失败原因
- android通过google api获取天气信息示例