用RelativeLayout实现上下控件高度不变,中间的控件高度随着屏幕高度变化,适应整个屏幕
2016-11-30 20:39
1726 查看
今天做一个界面做了很久
,又是获取屏幕高度,控件高度效果都不理想,先说说我想做什么吧!
整个布局分为上中下,上面LinearLayout写了一些基本信息,中间是一个RelativeLayout.,下面是用LinearLayout嵌套一个GridView,我是想中间的高度可以根据上下布局的变化而变化,从而能够恰好布满整个屏幕,开始我是获取上下布局的高度和屏幕的高度相减得到中间的高度,这样做也是可以的,但是就是加载的时候反应较慢,效果看起来很不理想,也可能是我方法不对吧。然后发现其实布局就能搞定
,因为费心好久,所以写一个博客记住,免得下次又来。。。
上布局:
gridview是固定的几个模块,高度没什么大的变化,然后就是这样啦。。
ok,说到这里,就算完了,希望能对大家有点用处
,拜~
,又是获取屏幕高度,控件高度效果都不理想,先说说我想做什么吧!
整个布局分为上中下,上面LinearLayout写了一些基本信息,中间是一个RelativeLayout.,下面是用LinearLayout嵌套一个GridView,我是想中间的高度可以根据上下布局的变化而变化,从而能够恰好布满整个屏幕,开始我是获取上下布局的高度和屏幕的高度相减得到中间的高度,这样做也是可以的,但是就是加载的时候反应较慢,效果看起来很不理想,也可能是我方法不对吧。然后发现其实布局就能搞定
,因为费心好久,所以写一个博客记住,免得下次又来。。。
上布局:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/content_bg"> <LinearLayout android:id="@+id/userInfo_view" android:layout_width="match_parent" android:layout_height="50dp" android:orientation="vertical" android:paddingBottom="10dp"> </LinearLayout> <RelativeLayout android:id="@+id/mapView_rl" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_above="@+id/gridview_ll" android:layout_below="@id/userInfo_view"> <RelativeLayout </RelativeLayout> <LinearLayout android:id="@+id/gridview_ll" android:layout_width="match_parent" android:layout_height="200dp" android:layout_alignParentBottom="true" android:gravity="center" android:paddingTop="8dp"> <GridView android:id="@+id/gridView" android:layout_width="match_parent" android:layout_height="wrap_content" android:horizontalSpacing="2dp" android:numColumns="2" android:stretchMode="columnWidth" android:verticalSpacing="2dp" /> </LinearLayout> </RelativeLayout>
gridview是固定的几个模块,高度没什么大的变化,然后就是这样啦。。
ok,说到这里,就算完了,希望能对大家有点用处
,拜~
相关文章推荐
- Android界面控件遍历代码 改变宽度 高度 字体大小适应屏幕
- C++ MFC控件随着窗口大小变化而自适应
- 微信小程序中使元素占满整个屏幕高度实现方法
- css实现高度height随宽度width变化保持比例不变
- CFormView上让控件的大小随着窗体的变化而自动适应
- wpf 中借助 Grid 实现随着 Form 大小变化而按比例自动改变宽度或高度。
- UIWebView 实现图片适应屏幕的宽度 文字内容的大小不变
- css实现容器高度 适应 屏幕高度
- (div+css)上下固定中间自适应高度网页布局的实现
- RelativeLayout(Android)中实现控件平分屏幕
- <Android> 利用RelativeLayout实现中间控件长度自适应
- javascript实现页面右侧在线客服始终跟随鼠标滚动而上下滚动且始终位于屏幕中间
- (div+css)上下固定中间自适应高度网页布局的实现(FF,IE)
- 如何实现ScrolledComposite下 控件个数随着窗口大小自动变化
- 上下Div固定,中间div高度自适应(随浏览器高度变化而变化)
- 简单实现ImageView宽度填满屏幕,高度自适应的两种方式
- css实现容器高度 适应 屏幕高度
- [CSS]使用绝对定位属性来实现CSS内部子容器高度随着外部父容器高度变化而变化
- CSS实现自适应高度布局:头部底部固定,中间自适应铺满屏幕剩余高度,中间盒子里左盒子固定右盒子自适应宽度
- (div+css)上下固定中间自适应高度网页布局的实现(FF,IE)