zoukankan      html  css  js  c++  java
  • Android布局方式_RelativeLayout

    RelativeLayout(相对布局)允许子元素指定它们相对于其他元素或父元素的位置(通过ID指定),因此用户可以右对齐,或上下对齐,或置于屏幕中央的形式来排列两个元素。

    RelativeLayout的属性如下:

    // 相对于给定ID控件

    android:layout_above 将该控件的底部置于给定ID的控件之上;

    android:layout_below 将该控件的底部置于给定ID的控件之下;

    android:layout_toLeftOf    将该控件的右边缘与给定ID的控件左边缘对齐;

    android:layout_toRightOf  将该控件的左边缘与给定ID的控件右边缘对齐;

    android:layout_alignBaseline  将该控件的baseline与给定ID的baseline对齐;

    android:layout_alignTop        将该控件的顶部边缘与给定ID的顶部边缘对齐;

    android:layout_alignBottom   将该控件的底部边缘与给定ID的底部边缘对齐;

    android:layout_alignLeft        将该控件的左边缘与给定ID的左边缘对齐;

    android:layout_alignRight      将该控件的右边缘与给定ID的右边缘对齐;

    // 相对于父组件

    android:layout_alignParentTop      如果为true,将该控件的顶部与其父控件的顶部对齐;

    android:layout_alignParentBottom 如果为true,将该控件的底部与其父控件的底部对齐;

    android:layout_alignParentLeft      如果为true,将该控件的左部与其父控件的左部对齐;

    android:layout_alignParentRight    如果为true,将该控件的右部与其父控件的右部对齐;

    // 居中

    android:layout_centerHorizontal 如果为true,将该控件的置于水平居中;

    android:layout_centerVertical     如果为true,将该控件的置于垂直居中;

    android:layout_centerInParent   如果为true,将该控件的置于父控件的中央;

    // 指定移动像素

    android:layout_marginTop      上偏移的值;

    android:layout_marginBottom 下偏移的值;

    android:layout_marginLeft   左偏移的值;

    android:layout_marginRight   右偏移的值;

    example:

    android:layout_below = "@id/***"

    android:layout_alignBaseline = "@id/***"

    android:layout_alignParentTop = true

    android:layout_marginLeft = “10px”

  • 相关阅读:
    jstree 实现异步加载子节点
    创建 widget 窗口小组件
    Android(permission)常用权限
    Android 之 补间动画
    补间动画之 AlphaAnimation
    (转)向对象开发与面向组件开发的区别
    Android Drawable文件夹对应像素密度
    Notification(通知) 简单用法
    AlarmManager 用法
    关于IntentService 用法
  • 原文地址:https://www.cnblogs.com/bincoding/p/4975803.html
Copyright © 2011-2022 走看看