Android,android官網

來源:互聯網
上載者:User

Android,android官網
RelativeLayout布局


本文地址:http://blog.csdn.net/caroline_wendy


RelativeLayout是一種相對布局方式,是根據屬性進行對齊;A Layout where the positions of the children can be described in relation to each other or to the parent.在布局中,子控制項的位置根據相互之間的關係進行描述。Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. 子控制項之間不能存在循環相依性。
Note: In platform version 17 and lower, RelativeLayout was affected by a measurement bug that could cause child views to be measured with incorrect MeasureSpec values. This was triggered when a RelativeLayout container was placed in a scrolling container, such as a ScrollView or HorizontalScrollView. If a custom view not equipped to properly measure with the MeasureSpec mode UNSPECIFIED was placed in a RelativeLayout, this would silently work anyway as RelativeLayout would pass a very large AT_MOST MeasureSpec instead.This behavior has been preserved for apps that set android:targetSdkVersion="17" or older in their manifest's uses-sdk tag for compatibility. Apps targeting SDK version 18 or newer will receive the correct behavior

屬性名稱

描述

android:layout_below

擺放在指定組件的下邊

android:layout_toLeftOf

擺放在指定組件的左邊

android:layout_toRightOf

擺放在指定組件的右邊

android:layout_alignTop

以指定組件作為參考進行上對齊

android:layout_algnBottom

以指定組件作為參照進行下對齊

android:layout_alignLeft

以指定組件作為參考進行靠左對齊

android:layout_alignRight

以指定組件

 
android:layout_toStartOf="@+id/buttonTweet” //表是在某個控制項的前對齊,如果不知道,就圖形介面拖動
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:paddingBottom="@dimen/activity_vertical_margin"    tools:context=".StatusActivity">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/button_tweet"        android:id="@+id/buttonTweet"        android:layout_alignParentEnd="true"/>    <EditText        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:inputType="textMultiLine"        android:ems="10"        android:id="@+id/editText"        android:layout_alignParentBottom="true"        android:layout_alignParentStart="true"        android:hint="@string/hint_status"        android:layout_toStartOf="@+id/buttonTweet"/>    <TextView        android:id="@+id/textCount"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignEnd="@id/buttonTweet"        android:layout_below="@id/buttonTweet"        android:text="140"        android:textAppearance="?android:textAppearanceSmall"/></RelativeLayout>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.