RelativeLayout—相对布局


•相对布局内的子组件的位置总是相对于兄弟组件或父容器的位置来确

定。供子组件使用的主要属性:

•子组件相对于父容器

•android:layout_alignParentLeft="true":在父元素内左边

•android:layout_alignParentRight="true":在父元素内右边

•android:layout_alignParentTop="true":在父元素内顶部

•android:layout_alignParentBottom="true":在父元素内底部

•子组件相对于兄弟组件

•android:layout_below="@id/aaa":在指定View的下方

•android:layout_above="@id/xxx":在指定View的上方

•android:layout_toLeftOf="@id/bbb":在指定View的左边

•android:layout_toRightOf="@id/cccc":在指定View的右边

RelativeLayout—相对布局

•子组件的对齐方式:

•android:layout_centerInParent="true":居中布局

•android:layout_centerVertical="true":垂直居中布局

•android:layout_centerHorizontal="true":水平居中布局

•android:layout_alignTop="@id/xxx":不指定View的上边界一致

•android:layout_alignBottom="@id/xxx":不指定View下边界一致

•android:layout_alignLeft="@id/xxx":不指定View的左边界一致

•android:layout_alignRight="@id/xxx":不指定View的右边界一致

•Activity全屏

•android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"

•Activity去标题栏

•android:theme="@android:style/Theme.Holo.Light.NoActionBar "

         <?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="wrap_content">

    <TextView

        android:id="@+id/tv_1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="@string/framelayout_title"

        android:layout_alignParentTop="true"

        android:layout_alignParentLeft="true"

        android:textSize="18sp"

        android:textStyle="bold"

        android:textColor="#536D86"

        android:background="@drawable/bar_bg"

        android:gravity="center"/>

   

    <ImageView android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/btn_edit"

       android:layout_alignLeft="@id/tv_1"

        android:layout_alignTop="@id/tv_1"

        android:contentDescription="@string/blank"

        android:layout_gravity="left|top"/>

   

    <ImageView android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:src="@drawable/btn_refresh"

        android:layout_alignRight="@id/tv_1"

        android:layout_alignTop="@id/tv_1"

        android:contentDescription="@string/blank"

        android:layout_gravity="left|top"/>

 

</RelativeLayout>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值