layout_weight=1与wrap_content的使用
2016-01-13 11:52
302 查看
在一个布局中,分上下两层,如果想要使最下层wrap_content,上层占剩余的全部空间,就要让上层使用android:layout_height=”0dp”,android:layout_weight=”1”属性,下层使用android:layout_height=”wrap_content”属性。layout_weight=1是指该控件显示除去wrap_content控件所占大小的其他剩余空间,如果wrap_content中没有内容,那么layout_weight=1的控件占全部内容(三层也适用)
代码如下
效果图如下:
代码如下
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </FrameLayout> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none" android:layout_gravity="bottom"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center_vertical" > <GridView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:listSelector="@color/transparent_background"> </GridView> </LinearLayout> </HorizontalScrollView> </LinearLayout>
效果图如下:
相关文章推荐
- LeetCode_OJ【43】Multiply Strings
- HP-Unix Top命令总结
- hdoj Fast Food (单线DP)n个超市中选m个建仓库使距离最短
- Android新组件CoordinatorLayout协调布局的使用,结合TabLayout,结合DrawerLayout
- 学习web测试
- c#源代码—演示类的继承性,类的多态性
- Lucene索引,查询及高亮显示
- [转载]Android应用程序通用自动脱壳方法研究
- Linux kill 杀死指定进程
- 设置内存管理
- 【转】SSH 协议与OpenSSH详解
- (转)Android10_Intent及其七大属性及intent-filter设置
- UILabel的使用及常用属性的设置
- mysql显示行号
- VS2015开发的Office Addin部署,安装时报错:无法解析属性“type”的值。
- hdu1569find the safest road(floyd变形求最大安全值)
- ActiveMQ(5.10.0) - Configuring the simple authentication plug-in
- 程序测试概论与单元测试详解
- Android Log 工具类
- 电信SMGP协议,基于开源的jar文件smgpapi20100113.jar进行实现