3 RelativeLayout

子控件的位置是相对兄弟控件或父控件的位置而决定的。ViewA的位置相对于ViewB来决定,要保证B出现在A之前。

属性名称 属性说明
android:layout_centerHorizontal 当前控件位于父控件的横向中间位置
android:layout_centerVertical 当前控件位于父控件的纵向中间位置
android:layout_centerParent 当前控件位于父控件的纵横向中间位置
android:layout_alignParentBottom 当前控件低端与父控件的低端对齐
android:layout_alignParentLeft 当前控件左端与父控件的左端对齐
android:layout_alignParentRight 当前控件右端与父控件的右端对齐
android:layout_alignParentTop 当前控件上端与父控件的上端对齐
android:layout_alignWithParentIfMissing 参照控件不存在或不可见时参照父控件
   
android:layout_toRightOf 使当前控件位于给出id控件的右侧
android:layout_toLeftOf  
android:layout_above  
android:layout_below  
android:layout_alignTop  
android:layout_alignBottom  
android:layout_alignLeft  
android:layout_alignRight  
   
android:layout_marginLeft 当前控件左侧的留白
android:layout_marginRight  
android:layout_marginTop  
android:layout_marginBottom  

relavitelayout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:andro />
</RelativeLayout>

Android 布局管理器 之 RelativeLayout&FrameLayout&AbsoluteLayout

4 FrameLayout

在FrameLayout中,子控件是通过栈来绘制的,所有后添加的子控件会被绘制在上层

属性名称 对应方法 描述
android:foreground setForeground(Drawable) 设置绘制在所有控件之上
android:foregroundGravity setForegroundGravity(int) 设置绘制在所有子控件之上内容的gravity属性

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:andro />
</FrameLayout>

Android 布局管理器 之 RelativeLayout&FrameLayout&AbsoluteLayout

5 AbsoluteLayout

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:andro></Button>
</AbsoluteLayout>

Android 布局管理器 之 RelativeLayout&FrameLayout&AbsoluteLayout

相关文章:

  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-12
  • 2021-10-01
  • 2021-09-28
  • 2021-11-29
  • 2021-06-25
  • 2022-12-23
相关资源
相似解决方案