<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/online_error_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" > <ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:focusableInTouchMode="false"
android:src="@drawable/wifi_open" /> <TextView
android:id="@+id/tv_nonet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/imageView1"
android:layout_marginTop="2dp"
android:text="@string/online_error_tip"
android:textColor="@color/zz_black_60_percent_transparent"
android:textSize="13sp" /> <Button
android:id="@+id/online_error_btn_retry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_nonet"
android:layout_marginTop="40dp"
android:layout_marginBottom="14dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/online_error_retry"
android:textSize="15sp" />
</RelativeLayout>

一开始的时候布局是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/online_error_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical" > <ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"
android:focusableInTouchMode="false"
android:src="@drawable/wifi_open" /> <Button
android:id="@+id/online_error_btn_retry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="14dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:text="@string/online_error_retry"
android:textSize="15sp" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@+id/imageView1"
android:layout_marginTop="2dp"
android:text="@string/online_error_tip"
android:textColor="@color/zz_black_60_percent_transparent"
android:textSize="13sp" /> </RelativeLayout>

没想到relativeLayout的grivate :center会影响到

我把bottom的那个东西删除之后的布局。就是整个布局都会居中,而不是全屏的显示了。

如果有空间贴着父控件的底部,

 android:layout_alignParentBottom="true"

,那么grivate =center不会有太大的作用,因为整个布局已经被占用完了,而如果你没有这个控件,你还写了grivate =center,那么控件的

android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp"

控件的marginTop就会在布局的中间算margin,而不是顶部。

有grivate=center的布局效果:

没有grivate=center的布局效果:

最新文章

  1. 设计模式之合成/聚合利用原则(CARP)
  2. SimpleAdapter的使用
  3. 数据存储之Cookie和Web Storage。
  4. ajax请求(二),后台返回的JSon字符串的转换
  5. Jakarta-Commons- BeanUtils学习笔记:
  6. Android中的FrameLayout帧布局
  7. ArcGIS API for Silverlight学习笔记
  8. Linux基本操作 2-----Linux文件系统基本结构
  9. 显示器 RUIGE瑞鸽高清显示器TL-S1700HD
  10. E. Riding in a Lift(Codeforces Round #274)
  11. python decorator 基础
  12. Vue之七导航守卫
  13. VMware Workstation 12 Pro安装CentOs图文教程(超级详细)
  14. 七.HTTP协议原理介绍
  15. IntelliJ IDEA 中的Java程序目录结构
  16. 51Nod1367 完美森林 贪心
  17. The folder can’t be opened because you don’t have permission to see its contents.
  18. ZH奶酪:JavaScript调用AngularJS的函数/$scope/变量
  19. hdu-1060(数学问题)
  20. Java提供了哪些IO方式?IO, BIO, NIO, AIO是什么?

热门文章

  1. Struts2_简单数据验证
  2. nvd3基于时间轴流程图
  3. MongoDB 安装笔记
  4. thinkphp的find()方法获取结果
  5. mysql在控制台里出现中文问号问题
  6. 译:Local Spectral Graph Convolution for Point Set Feature Learning-用于点集特征学习的局部谱图卷积
  7. UIView设置阴影无效的原因之一
  8. AVR446_Linear speed control of stepper motor步进电机曲线分析
  9. 如何在spring中运行多个schedulers quartz 实例
  10. Python中的__name__和__main__含义详解