6

Android入门第6天-RelativeLayout

 1 year ago
source link: https://blog.csdn.net/lifetragedy/article/details/127705059
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

这个RelativeLayout很有意思。

它主要有以下几种用法我和大家说一下:

  1. layout_toLeftOf
  2. layout_toRightOf
  3. layout_above
  4. layout_centerHorizontal

这几个“方位”的后面都是跟着另外一个控件的。

比较著名的来一下把这几个方位都说清的有一种叫“梅花局”,我就用梅花局来说清这个问题吧。

以一个例子说通Relative布局

042efb41153046b79261bf7a8208df86.png

上面这个界面就是梅花布局。

设计上来看如何使用RelativeLayout布局来满足。

  1. 先从当中这个图片下手,把这个图片记成ID:img3,把它放在第一行代码;
  2. 左边的ID:img4,android:layout_toLeftOf="@id/img3";
  3. 右边的ID:img5,layout_toRightOf="@id/img3";
  4. 上边的ID:img1,android:layout_above="@id/img3"并且:android:layout_centerHorizontal="true",居中显示;
  5. 下面的ID:img2,android:layout_centerHorizontal="true

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK