Home | History | Annotate | Download | only in layout
      1 <?xml version="1.0" encoding="utf-8"?>
      2 <!-- Copyright (C) 2008 The Android Open Source Project
      3 
      4      Licensed under the Apache License, Version 2.0 (the "License");
      5      you may not use this file except in compliance with the License.
      6      You may obtain a copy of the License at
      7 
      8          http://www.apache.org/licenses/LICENSE-2.0
      9 
     10      Unless required by applicable law or agreed to in writing, software
     11      distributed under the License is distributed on an "AS IS" BASIS,
     12      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13      See the License for the specific language governing permissions and
     14      limitations under the License.
     15 -->
     16 
     17 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     18     android:layout_width="match_parent"
     19     android:layout_height="match_parent">
     20 
     21     <RelativeLayout
     22         android:id="@+id/relative_sublayout_attrs"
     23         android:background="@drawable/blue"
     24         android:layout_width="match_parent"
     25         android:layout_height="match_parent">
     26 
     27         <!-- view1, centered within its parent. -->
     28         <TextView
     29             android:id="@+id/relative_view1"
     30             android:layout_width="wrap_content"
     31             android:layout_height="wrap_content"
     32             android:layout_centerInParent="true"
     33             android:text="@string/relative_view1"/>
     34 
     35         <!-- view2, below view1 and has same left position with view1. -->
     36         <TextView
     37             android:id="@+id/relative_view2"
     38             android:layout_width="wrap_content"
     39             android:layout_height="wrap_content"
     40             android:layout_below="@id/relative_view1"
     41             android:layout_alignLeft="@id/relative_view1"
     42             android:text="@string/relative_view2"/>
     43 
     44         <!-- view3, has same top position with view1 and same bottom position with view2,
     45              and on the right of view1. -->
     46         <TextView
     47             android:id="@+id/relative_view3"
     48             android:layout_width="wrap_content"
     49             android:layout_height="wrap_content"
     50             android:layout_alignTop="@id/relative_view1"
     51             android:layout_alignBottom="@id/relative_view2"
     52             android:layout_toRightOf="@id/relative_view1"
     53             android:text="@string/relative_view3"/>
     54 
     55         <!-- view4, has same right position with view3 and above view3. -->
     56         <TextView
     57             android:id="@+id/relative_view4"
     58             android:layout_width="wrap_content"
     59             android:layout_height="wrap_content"
     60             android:layout_alignRight="@id/relative_view3"
     61             android:layout_above="@id/relative_view3"
     62             android:text="@string/relative_view4"/>
     63 
     64         <!-- view5 goes on the left-bottom -->
     65         <TextView
     66             android:id="@+id/relative_view5"
     67             android:layout_width="wrap_content"
     68             android:layout_height="wrap_content"
     69             android:layout_alignParentBottom="true"
     70             android:layout_alignParentLeft="true"
     71             android:text="@string/relative_view5"/>
     72 
     73         <!-- view6 goes on the top-right -->
     74         <TextView
     75             android:id="@+id/relative_view6"
     76             android:layout_width="wrap_content"
     77             android:layout_height="wrap_content"
     78             android:layout_alignParentTop="true"
     79             android:layout_alignParentRight="true"
     80             android:text="@string/relative_view6"/>
     81 
     82         <!-- view7, has same baseline with view6 and centered horizontally within its parent. -->
     83         <TextView
     84             android:id="@+id/relative_view7"
     85             android:layout_width="wrap_content"
     86             android:layout_height="wrap_content"
     87             android:layout_alignBaseline="@id/relative_view6"
     88             android:layout_centerHorizontal="true"
     89             android:text="@string/relative_view7"/>
     90 
     91         <!-- view8, centered vertically within its parent and on the left of view1. -->
     92         <TextView
     93             android:id="@+id/relative_view8"
     94             android:layout_width="wrap_content"
     95             android:layout_height="wrap_content"
     96             android:layout_toLeftOf="@id/relative_view1"
     97             android:layout_centerVertical="true"
     98             android:text="@string/relative_view8"/>
     99 
    100         <!-- view9, has same top and bottom position with view3 and same left position
    101              with its parent. -->
    102         <TextView
    103             android:id="@+id/relative_view9"
    104             android:layout_width="wrap_content"
    105             android:layout_height="wrap_content"
    106             android:layout_alignLeft="@id/gravity_bottom"
    107             android:layout_alignTop="@id/relative_view3"
    108             android:layout_alignBottom="@id/relative_view3"
    109             android:layout_alignWithParentIfMissing="true"
    110             android:text="@string/relative_view9"/>
    111 
    112     </RelativeLayout>
    113 
    114     <RelativeLayout
    115         android:id="@+id/relative_sublayout_gravity"
    116         android:background="@drawable/yellow"
    117         android:layout_width="match_parent"
    118         android:layout_height="match_parent">
    119 
    120         <!-- view10 -->
    121         <TextView
    122             android:id="@+id/relative_view10"
    123             android:layout_width="wrap_content"
    124             android:layout_height="wrap_content"
    125             android:text="@string/relative_view10"/>
    126 
    127         <!-- view11 -->
    128         <TextView
    129             android:id="@+id/relative_view11"
    130             android:layout_width="wrap_content"
    131             android:layout_height="wrap_content"
    132             android:layout_below="@id/relative_view10"
    133             android:text="@string/relative_view11"/>
    134     </RelativeLayout>
    135 
    136     <RelativeLayout
    137         android:id="@+id/relative_sublayout_ignore_gravity"
    138         android:background="@drawable/red"
    139         android:layout_width="match_parent"
    140         android:layout_height="match_parent"
    141         android:ignoreGravity="@+id/relative_view12"
    142         android:gravity="right">
    143 
    144         <!-- view12 -->
    145         <TextView
    146             android:id="@id/relative_view12"
    147             android:layout_width="wrap_content"
    148             android:layout_height="wrap_content"
    149             android:text="@string/relative_view12"/>
    150 
    151         <!-- view13 -->
    152         <TextView
    153             android:id="@+id/relative_view13"
    154             android:layout_width="wrap_content"
    155             android:layout_height="wrap_content"
    156             android:text="@string/relative_view13"/>
    157     </RelativeLayout>
    158 
    159     <Spinner
    160         android:id="@+id/spinner1"
    161         android:layout_width="match_parent"
    162         android:layout_height="match_parent"
    163         android:prompt="@string/text_view_hello"/>
    164 
    165     <RelativeLayout
    166             android:id="@+id/relative_sublayout_attrs_2"
    167             android:background="@drawable/blue"
    168             android:layout_width="match_parent"
    169             android:layout_height="match_parent">
    170 
    171         <!-- view21, centered within its parent. -->
    172         <TextView
    173                 android:id="@+id/relative_view21"
    174                 android:layout_width="wrap_content"
    175                 android:layout_height="wrap_content"
    176                 android:layout_centerInParent="true"
    177                 android:text="@string/relative_view1"/>
    178 
    179         <!-- view22, below view1 and has same start position with view21. -->
    180         <TextView
    181                 android:id="@+id/relative_view22"
    182                 android:layout_width="wrap_content"
    183                 android:layout_height="wrap_content"
    184                 android:layout_below="@id/relative_view21"
    185                 android:layout_alignStart="@id/relative_view21"
    186                 android:text="@string/relative_view2"/>
    187 
    188         <!-- view23, has same top position with view21 and same bottom position with view22,
    189              and on the end of view1. -->
    190         <TextView
    191                 android:id="@+id/relative_view23"
    192                 android:layout_width="wrap_content"
    193                 android:layout_height="wrap_content"
    194                 android:layout_alignTop="@id/relative_view21"
    195                 android:layout_alignBottom="@id/relative_view22"
    196                 android:layout_toEndOf="@id/relative_view21"
    197                 android:text="@string/relative_view3"/>
    198 
    199         <!-- view24, has same end position with view23 and above view23. -->
    200         <TextView
    201                 android:id="@+id/relative_view24"
    202                 android:layout_width="wrap_content"
    203                 android:layout_height="wrap_content"
    204                 android:layout_alignEnd="@id/relative_view23"
    205                 android:layout_above="@id/relative_view23"
    206                 android:text="@string/relative_view4"/>
    207 
    208         <!-- view25 goes on the start-bottom -->
    209         <TextView
    210                 android:id="@+id/relative_view25"
    211                 android:layout_width="wrap_content"
    212                 android:layout_height="wrap_content"
    213                 android:layout_alignParentBottom="true"
    214                 android:layout_alignParentStart="true"
    215                 android:text="@string/relative_view5"/>
    216 
    217         <!-- view26 goes on the top-end -->
    218         <TextView
    219                 android:id="@+id/relative_view26"
    220                 android:layout_width="wrap_content"
    221                 android:layout_height="wrap_content"
    222                 android:layout_alignParentTop="true"
    223                 android:layout_alignParentEnd="true"
    224                 android:text="@string/relative_view6"/>
    225 
    226         <!-- view27, has same baseline with view26 and centered horizontally within its parent. -->
    227         <TextView
    228                 android:id="@+id/relative_view27"
    229                 android:layout_width="wrap_content"
    230                 android:layout_height="wrap_content"
    231                 android:layout_alignBaseline="@id/relative_view26"
    232                 android:layout_centerHorizontal="true"
    233                 android:text="@string/relative_view7"/>
    234 
    235         <!-- view28, centered vertically within its parent and on the start of view21. -->
    236         <TextView
    237                 android:id="@+id/relative_view28"
    238                 android:layout_width="wrap_content"
    239                 android:layout_height="wrap_content"
    240                 android:layout_toStartOf="@id/relative_view21"
    241                 android:layout_centerVertical="true"
    242                 android:text="@string/relative_view8"/>
    243 
    244         <!-- view29, has same top and bottom position with view23 and same start position
    245              with its parent. -->
    246         <TextView
    247                 android:id="@+id/relative_view29"
    248                 android:layout_width="wrap_content"
    249                 android:layout_height="wrap_content"
    250                 android:layout_alignStart="@id/gravity_bottom"
    251                 android:layout_alignTop="@id/relative_view23"
    252                 android:layout_alignBottom="@id/relative_view23"
    253                 android:layout_alignWithParentIfMissing="true"
    254                 android:text="@string/relative_view9"/>
    255 
    256     </RelativeLayout>
    257 
    258 </RelativeLayout>
    259