RelativeLayout布局 
android:layout_marginTop="25dp" //距离顶部距离 25dp(dp为单位)
android:gravity="left" //控件本身的布局位置 
android:layout_marginLeft="15dp //距离左边距 

// 相对于给定ID控件 即引用id,书写时不用使用+形式为@id/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   //右偏移的值;

 

 

详细解释:

android:layout_alignParentRight="true" 
//使当前控件的右端和父控件的右端对齐。这里属性值只能为true或false,默认false。 
android:layout_marginLeft="10dp" 
//使当前控件左边空出指定的相应空间。 
android:layout_toLeftOf="@id/ok" 
//使当前控件置于id为ok的控件的左边。 
android:layout_alignTop="@id/ok" 
//使当前控件与id控件的上端对齐。 
padding表示填充,margin表示边距 
可通过android:padding属性进行设置,4个方向的边距属性为android:paddingLeft, android:paddingRight, android:paddingTop, and android:paddingBottom. 

 

结论: 
*android:layout_marginBottom 
*android:layout_marginLeft 
*android:layout_marginRight 
*android:layout_marginTop 
上面几个属性的值是根据下面的相对位置的对象的值来做计算的,如果没有相对的对象就以总体布局来计算 
*android:layout_below 
*android:layout_above 
*android:layout_toLeftOf 
*android:layout_toRightOf 
*android:layout_alignTop 


*android:layout_centerHrizontal          //是否支持横屏或竖屏 
*android:layout_centerVertical             //这个根据单词的意思:中心垂直 
*android:layout_centerInparent         // 
android:layout_centerInParent="true"//居中在父对象 
android:layout_centerInParent="false" ... 浏览器不支持多窗口显示,意思就是说所有页面在单一窗口打开,这样避免了页面布局控制显示问题 
下面的相对于父的相对位置 
*android:layout_alignParentBottom 
*android:layout_alignParentLeft 
*android:layout_alignParentRight 
*android:layout_alignParentTop 
*android:layout_alignWithParentIfMissing 

更多相关文章

  1. 相对布局RelativeLayout的妙用:提示标签在输入框内
  2. 【Android开发学习27】界面控件之进度条(ProgressBar)
  3. Android开发布局系列: LinearLayout布局实现垂直水平居中
  4. 【Android-002】【常见布局】
  5. ArcGIS for Android地图控件的5大常见操作
  6. android布局的一些知识
  7. Android studio中相对布局组件排列方式
  8. TextView 控件使用

随机推荐

  1. Android Eclipse关联 android API doc文
  2. android - AsyncTask的使用
  3. Android布局优化之Include(一)
  4. 浅入浅出 Android(安卓)安全:第六章 Andro
  5. android ContentProvider使用详解
  6. 这篇文章适合所有Android手机第一次买And
  7. 分别在Linux和Android中用C语言写系统日
  8. Mac OS X下用Eclipse浏览和编译Android源
  9. Android之网络请求2————OkHttp的基本
  10. 高通平台android 环境配置编译及开发经验