果酿吧 关注:14贴子:1,065
  • 3回复贴,共1
下面是RelativeLayout各个属性
android:layout_above="@id/xxx" --将控件置于给定ID控件之上
android:layout_below="@id/xxx" --将控件置于给定ID控件之下
android:layout_toLeftOf="@id/xxx" --将控件的右边缘和给定ID控件的左边缘对齐
android:layout_toRightOf="@id/xxx" --将控件的左边缘和给定ID控件的右边缘对齐
android:layout_alignLeft="@id/xxx" --将控件的左边缘和给定ID控件的左边缘对齐
android:layout_alignTop="@id/xxx" --将控件的上边缘和给定ID控件的上边缘对齐
android:layout_alignRight="@id/xxx" --将控件的右边缘和给定ID控件的右边缘对齐
android:layout_alignBottom="@id/xxx" --将控件的底边缘和给定ID控件的底边缘对齐
android:layout_alignParentLeft="true" --将控件的左边缘和父控件的左边缘对齐
android:layout_alignParentTop="true" --将控件的上边缘和父控件的上边缘对齐
android:layout_alignParentRight="true" --将控件的右边缘和父控件的右边缘对齐
android:layout_alignParentBottom="true" --将控件的底边缘和父控件的底边缘对齐
android:layout_centerInParent="true" --将控件置于父控件的中心位置
android:layout_centerHorizontal="true" --将控件置于水平方向的中心位置
android:layout_centerVertical="true" --将控件置于垂直方向的中心位置


IP属地:广东1楼2017-12-01 22:01回复
    android:layout_margin:本元素离上下左右间的距离
    android:layout_marginStart:本元素离开始的位置的距离
    android:layout_marginEnd:本元素离结束位置的距离


    IP属地:广东2楼2017-12-01 22:10
    回复
      android:gravity="center_vertical" 这个的意思是指 限定它里面的内容要垂直居中显示。
      android:layout_gravity="center_vertical",这个是指它的位置是相对于它父亲的垂直居中。
      比如:
      //第一种:里面的内容都要垂直居中显示,是由父类限定子控件的位置,每个子控件都要满足这个条件。
      <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center_vertical" //这个指里面的子内容要垂直居中显示
      >
      <TextView 这个 就会垂直居中显示
      android:layout_width="wrap_context"
      android:layout_height="wrap_context"/>
      />
      </LinearLayout>
      //第二种:是子控件自己去排位置,每个控件可以设置不同的
      <LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
      <TextView
      android:layout_width="wrap_context"
      android:layout_height="wrap_context"
      android:layout_gravity="center_vertical" //这个就是让他相对于父亲的垂直中间显示。
      />
      </LinearLayout>


      IP属地:广东3楼2017-12-01 22:39
      回复
        http://www.apkbus.com/code.php


        IP属地:广东来自Android客户端4楼2017-12-25 11:23
        回复