Android and android Official Website

Source: Internet
Author: User

Android and android Official Website
RelativeLayout Layout


Address: http://blog.csdn.net/caroline_wendy


RelativeLayoutIs A relative Layout method, Alignment Based on attributes; A Layout where the positions of the children can be described in relation to each other or to the parent. in the layout, the position of the child control is described based on the relationship between them. Note that you cannot have a circular dependency between the size of the RelativeLayout and the position of its children. circular dependencies cannot exist between child controls.
Note:In platform version 17 and lower, RelativeLayout was affected by a measurement bug that cocould 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 wowould silently work anyway as RelativeLayout wocould 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

Attribute name

Description

Android: layout_below

Placed under the specified component

Android: layout_toLeftOf

Placed on the left of the specified component

Android: layout_toRightOf

Placed on the right of the specified component

Android: layout_alignTop

Alignment with specified components as reference

Android: layout_algnBottom

Bottom alignment with specified component as reference

Android: layout_alignLeft

Align left with specified components as reference

Android: layout_alignRight

To specify Components

 
Android: layout_toStartOf = "@ + id/buttonTweet" // The table is aligned before a control. If you do not know it, drag it to the graphic interface.
<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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.