zoukankan      html  css  js  c++  java
  • android系列6.RelativeLayout学习

    相对布局 RelativeLayout 允许子元素指定它们相对于其父元素或兄弟元素的位置

    RelativeLayout的一些属性:

    第一类:属性值为true或false
    android:layout_centerHrizontal                                           水平居中
    android:layout_centerVertical                                            垂直居中
    android:layout_centerInparent                                           相对于父元素完全居中
    android:layout_alignParentBottom                                     贴紧父元素的下边缘
    android:layout_alignParentLeft                                          贴紧父元素的左边缘
    android:layout_alignParentRight                                        贴紧父元素的右边缘
    android:layout_alignParentTop                                          贴紧父元素的上边缘
    android:layout_alignWithParentIfMissing                            如果对应的兄弟元素找不到的话就以父元素做参照物

    第二类:属性值必须为id的引用名“@id/id-name”
    android:layout_below                          在某元素的下方
    android:layout_above                          在某元素的的上方
    android:layout_toLeftOf                       在某元素的左边
    android:layout_toRightOf                     在某元素的右边

    android:layout_alignTop                      本元素的上边缘和某元素的的上边缘对齐
    android:layout_alignLeft                      本元素的左边缘和某元素的的左边缘对齐
    android:layout_alignBottom                 本元素的下边缘和某元素的的下边缘对齐
    android:layout_alignRight                    本元素的右边缘和某元素的的右边缘对齐

    第三类:属性值为具体的像素值,如30dip,40px
    android:layout_marginBottom              离某元素底边缘的距离
    android:layout_marginLeft                   离某元素左边缘的距离
    android:layout_marginRight                 离某元素右边缘的距离
    android:layout_marginTop                   离某元素上边缘的距离

    第三类:属性值为具体的像素值,属性为true,false
    android:layout_alignParentLeft      相对父控件左部
    android:layout_alignParentRight    相对父控件右部
    android:layout_alignParentTop      相对父控件顶部
    android:layout_alignParentButtom   相对父控件底部

    关于边距问题:
    padding是控件的内容相对控件的边缘的边距. 
    margin是控件边缘相对父空间的边距.

    示例Demo:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="fill_parent"
     4     android:layout_height="wrap_content"
     5     android:padding="10px"
     6     android:background="#ff00ff"
     7     >
     8 <TextView  
     9     android:id="@+id/tv01"
    10     android:layout_width="fill_parent" 
    11     android:layout_height="wrap_content" 
    12     android:text="Type Here:"
    13     />
    14 <EditText
    15     android:id="@+id/et01" 
    16     android:layout_width="fill_parent"
    17     android:layout_height="wrap_content"
    18     android:layout_below="@id/tv01"
    19 />
    20 <Button 
    21     android:id="@+id/btnOk"
    22     android:layout_width="wrap_content"
    23     android:layout_height="wrap_content"
    24     android:text="OK"
    25     android:layout_below="@id/et01"
    26     android:layout_alignRight="@id/et01"
    27     android:layout_marginLeft="30dip"
    28 />
    29 <Button 
    30     android:id="@+id/btnCancel"
    31     android:layout_width="wrap_content"
    32     android:layout_height="wrap_content"
    33     android:text="Cancel"
    34     android:layout_toLeftOf="@id/btnOk"
    35     android:layout_alignTop="@id/btnOk"
    36 />
    37 </RelativeLayout>

  • 相关阅读:
    hdu 4777 树状数组+合数分解
    hdu5635 BestCoder Round #74 (div.2)
    hdu 5636 搜索 BestCoder Round #74 (div.2)
    hdu 5637 BestCoder Round #74 (div.2)
    hdu4605 树状数组+离散化+dfs
    hdu4521 线段树+dp
    hdu3340 线段树+多边形
    孜孜不倦,必能求索;风尘仆仆,终有归途。
    增加、删除类文件或者在一个类中增加、删除方法时,是不能够热部署到服务上的。这时候需要停止服务器重新部署后再启动,就不会出现上面的提示了。
    为什么jdk1.8不支持sql.append,该如何解决
  • 原文地址:https://www.cnblogs.com/atyou/p/2746065.html
Copyright © 2011-2022 走看看