Android相對布局執行個體

來源:互聯網
上載者:User

標籤:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/container"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.example.fingergame.MainActivity"    tools:ignore="MergeRootFrame"             >    <!-- 注釋不能寫在</>標記內 -->   <!--   android:layout_width="fill_parent"這與父組件左靠右對齊屬性結合的效果一致-->   <TextView        android:id="@+id/title"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_centerHorizontal="true"        android:layout_marginTop="5dp"        android:gravity="center_horizontal"        android:textSize="20sp"        android:textColor="#0000FF"        android:text="猜 拳 遊 戲"           />    <ImageView        android:id="@+id/photo1"        android:layout_below="@id/title"   android:layout_width="wrap_content"   android:layout_height="wrap_content"     android:layout_marginTop="18dp"   android:layout_marginLeft="60dp"   android:src="@drawable/smileface"        />        <ImageView        android:id="@+id/photo2"         android:layout_below="@id/title"        android:layout_toRightOf="@id/photo1"          android:layout_marginTop="18dp"   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:layout_marginLeft="80dp"   android:src="@drawable/smileface"        />    <RadioGroup         android:id="@+id/chose1"        android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:layout_marginTop="18dp"    android:layout_marginLeft="40dp"   android:layout_below="@id/photo1"   android:orientation="vertical"   >               <RadioButton        android:id="@+id/stone1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/photo1"        android:layout_toRightOf="@+id/chose1"         android:layout_marginTop="20dp"        android:checked="true"        android:text="石頭" />        <RadioButton        android:id="@+id/scissors1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/stone1"        android:layout_marginTop="20dp"        android:layout_toRightOf="@+id/chose1"        android:text="剪刀" />        <RadioButton        android:id="@+id/cloth1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/scissors1"        android:layout_marginTop="20dp"        android:layout_toRightOf="@+id/chose1"        android:text="布" />   </RadioGroup>     <!--   android:layout_height="wrap_content"以chose1的頭部對齊       比用android:layout_marginTop="20dp"更靈活 -->      <RadioGroup          android:id="@+id/chose2"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_alignTop="@+id/chose1"               android:layout_marginLeft="70dp"          android:layout_toRightOf="@+id/photo1"          android:orientation="vertical" >          <RadioButton              android:id="@+id/stone2"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@+id/chose1"              android:layout_marginTop="20dp"              android:layout_toRightOf="@+id/stone1"              android:checked="true"              android:text="石頭" />          <RadioButton              android:id="@+id/scissors2"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@+id/stone2"              android:layout_marginTop="20dp"              android:layout_toRightOf="@+id/scissors1"              android:text="剪刀" />          <RadioButton              android:id="@+id/cloth2"              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:layout_below="@+id/cloth1"              android:layout_marginTop="20dp"              android:layout_toRightOf="@+id/cloth1"              android:text="布" />      </RadioGroup>           <Button         android:id="@+id/ok1"              android:layout_width="75dp"              android:layout_height="35dp"              android:layout_below="@+id/chose1"              android:layout_marginTop="20dp"              android:layout_alignLeft="@+id/chose1"              android:text="確認"         />     <Button         android:id="@+id/ok2"              android:layout_width="75dp"              android:layout_height="35dp"              android:layout_below="@+id/chose2"              android:layout_marginTop="20dp"              android:layout_alignLeft="@+id/chose2"              android:text="確認"         />     <TextView         android:id="@+id/copyright"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentBottom="true"         android:layout_centerHorizontal="true"         android:layout_marginBottom="5dp"         android:text="©fingergame 2015   |   designer:Amy" /></RelativeLayout>

  運行結果:

 

Android相對布局執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.