首页 > 移动平台 > 详细

Android笔记:RelativeLayout

时间:2016-06-16 13:01:21      阅读:277      评论:0      收藏:0      [点我收藏+]

摘自《第一行代码》

RelativeLayout 又称作相对布局,也是一种非常常用的布局。和 LinearLayout 的排列规
则不同,RelativeLayout 显得更加随意一些,它可以通过相对定位的方式让控件出现在布局
的任何位置。

<?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" >
    
   
  <Button
  android:id="@+id/button1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:layout_alignParentTop="true"
  android:text="Button 1" />
  <Button
  android:id="@+id/button2"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentRight="true"
  android:layout_alignParentTop="true"
  android:text="Button 2" />
  <Button
  android:id="@+id/button3"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true"
  android:text="Button 3" />
  <Button
  android:id="@+id/button4"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:layout_alignParentLeft="true"
  android:text="Button 4" />
  <Button
  android:id="@+id/button5"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:layout_alignParentRight="true"
  android:text="Button 5" />
    
</RelativeLayout>

 

Android笔记:RelativeLayout

原文:http://www.cnblogs.com/expiator/p/5590459.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!