<?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的布局效果:

被relativeLayout的grivate center 折腾死了的更多相关文章

  1. 被这个C程序折腾死了

    The C programming language 的第13页,1.5.3 行计数的那里,那个统计换行符个数的程序我好像无法运行,无论输入什么,按多少下enter,什么都出不来. #include& ...

  2. 微信小程序开发心得

    微信小程序也已出来有一段时间了,最近写了几款微信小程序项目,今天来说说感受. 首先开发一款微信小程序,最主要的就是针对于公司来运营的,因为,在申请appid(微信小程序ID号)时候,需要填写相关的公司 ...

  3. [开源].NET高性能框架Chloe.ORM-完美支持.NET Core

    扯淡 这是一款轻量.高效的.NET C#数据库访问框架(ORM).查询接口借鉴 Linq(但不支持 Linq).借助 lambda 表达式,可以完全用面向对象的方式就能轻松执行多表连接查询.分组查询. ...

  4. Red Hat Enterprise Server 6.0 安装Sendmail相关包

    由于需要在Linux服务器(Red Hat Enterprise Linux Server release 6.0)上配置邮件服务,需要安装Sendmail包,一般Sendmail的安装有两种方式:R ...

  5. Fast RCNN 训练自己数据集 (2修改数据读取接口)

    Fast RCNN训练自己的数据集 (2修改读写接口) 转载请注明出处,楼燚(yì)航的blog,http://www.cnblogs.com/louyihang-loves-baiyan/ http ...

  6. 条件编译#if #ifdef

    近期由于一些莫名其妙的原因开始学c++,我觉得我哪天要是挂了也是被自己给折腾死的,算了,反正不是折腾死就是被淘汰,当是没事打发时间了,废话不多说,开始今天的主题. 之前接触的注释就是注释,条件语句就是 ...

  7. VS Code 开发asp.net core 遇到的坑

    摘要 微软发布.NET Core 1.0,ASP.NET Core 1.0 与 Entity Framewok 1.0也有一段时间了,一直没进行这方面的学习,节前公司让调研这方面的可行性.所以还是从最 ...

  8. 使用mvvm框架avalon开发公司内部运营管理系统的一些心得

    接触avalon差不多有一年时间了,当时是看前端大牛司徒正美的博客才了解到还有这么一个高大上的玩意,然后就加入了avalon的讨论群.从群里零零散散的了解了avalon的一些特性,感觉很强大,感觉思想 ...

  9. 解决Eclipse里Maven工程报 An error occurred while filtering resources错误

    这几天被maven的单元测试折腾死了,以为是自己的eclipse有问题呢,今天早上来了又发现eclipse报了一个很奇怪的错误:An error occurred while filtering re ...

随机推荐

  1. [javascript]什么是闭包?

    http://www.zcfy.cc/article/master-the-javascript-interview-what-is-a-closure-2127.html

  2. check_mk插件 redis

    /usr/lib/check_mk_agent/plugins/mk_redis #!/bin/bash echo '<<<redis>>>' hosts=$(ne ...

  3. python数组列表、字典、拷贝、字符串

    python中字符串方法 name = "I teased at life as if it were a foolish game" print(name.capitalize( ...

  4. POJ-3190 Stall Reservations---优先队列+贪心

    题目链接: https://vjudge.net/problem/POJ-3190 题目大意: 有N头奶牛,每头奶牛都会在[1,1000000]的时间区间内的子区间进行挤奶.挤奶的时候奶牛一定要单独放 ...

  5. bzoj4836 [Lydsy2017年4月月赛]二元运算

    Description 定义二元运算 opt 满足 现在给定一个长为 n 的数列 a 和一个长为 m 的数列 b ,接下来有 q 次询问.每次询问给定一个数字 c  你需要求出有多少对 (i, j) ...

  6. 【洛谷4459】[BJOI2018] 双人猜数游戏(动态规划)

    点此看题面 大致题意: 一直有两个数\(m,n\),已知\(s\le m\le n\),且\(Alice\)和\(Bob\)二个"最强大佬"各知道\(mn\)和\(m+n\).每轮 ...

  7. 找父节点和子节点个数(Poj1634)

    题目链接:http://poj.org/problem?id=1634 思路:按照工资从小到大排好,找到最近的那个身高较高的人. 有一点要注意的是,这里有个根节点,大boss,他的id是0,因此,我这 ...

  8. 引用类型(三):Function类型

    一. Function类型函数实际上是对象.每个函数都是Function类型都实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此函数名实际上也是一个指向函数对象都指针.1.函数通常是使 ...

  9. Veritas NetBackup™ 状态码"十大"常见报错状态码

    我在刚开始学习Netbackup的时候,没少走弯路.经常会遇到各种稀奇古怪的 error 信息,遇到报错会很慌张,急需一个解决问题的办法.跟无头苍蝇一样,会不加思索地把错误粘到百度上,希望赶紧查找一下 ...

  10. 2018.8.17 关于JavaScript的几种常见的全局函数

    JavaScript常见的全局函数 <!doctype html> <html lang="en"> <head> <meta chars ...