안 드 로 이 드 에서 include 태그 사용 분석

한 항목 에서 우 리 는 같은 레이아웃 디자인 을 사용 해 야 할 수도 있 습 니 다.xml 파일 에 쓰 여 있 으 면 코드 가 지루 하고 가 독성 이 떨 어 지기 때문에 같은 레이아웃 의 코드 를 하나의 모듈 로 만 든 다음 에 사용 할 때 라벨 을 통 해 layot 코드 를 다시 사용 할 수 있 습 니 다.app_title.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/titleLayout" android:layout_width="fill_parent" android:layout_height="wrap_content"
   android:background="@drawable/bt" xmlns:android="http://schemas.android.com/apk/res/android">

  <TextView android:text="@string/login" android:id="@+id/title" android:textSize="20px" android:textColor="@color/white"
   android:layout_width="wrap_content" android:layout_centerInParent="true" android:layout_height="wrap_content"/>  
  <Button android:text=" " android:id="@+id/refresh" android:layout_width="wrap_content" android:layout_height="wrap_content"
   android:layout_alignParentRight="true" android:focusable="false" android:textColor="@color/white"
   android:background="@drawable/okbutton" android:layout_marginRight="3px"/>
</RelativeLayout>
app_tradelogin.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- android:layout_below android:layout_above , , android:layout_above -->
<ScrollView android:layout_below="@+id/titleLayout" android:layout_above="@+id/appbottom" android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:layout_centerInParent="true" xmlns:android="http://schemas.android.com/apk/res/android">
 <LinearLayout android:id="@+id/theWholeLinearLayout" android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:paddingLeft="10px" android:paddingTop="6px" android:paddingRight="10px" >
  <LinearLayout android:id="@+id/linearLayoutLeft" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
   <TableLayout android:id="@+id/widget43" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" android:stretchColumns="1">
    <TableRow >
    <!--  TextView , , -->
     <TextView android:id="@+id/traderName" android:text="@string/traderName" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <Spinner android:id="@+id/traderNameS" android:layout_width="fill_parent" android:layout_height="wrap_content">
     </Spinner>
    </TableRow>

    <TableRow>
     <TextView android:id="@+id/departName" android:text="@string/departName" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <Spinner android:id="@+id/departNameS" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
    </TableRow>

    <TableRow >
     <TextView android:id="@+id/strComponyName" android:text="@string/accType" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <Spinner android:id="@+id/accTyte" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
    </TableRow>

    <TableRow >
     <TextView android:id="@+id/strUserAcc" android:text="@string/userAcc" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <EditText android:id="@+id/accEditText" android:text="" android:numeric="decimal" style="@style/StyleEditText1" mce_style="@style/StyleEditText1"/>
    </TableRow>

    <TableRow >
     <TextView android:id="@+id/userPwd" android:text="@string/userPWD" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <EditText android:id="@+id/userPwdET" android:text="" android:password="true" style="@style/StyleEditText1" mce_style="@style/StyleEditText1"/>
    </TableRow>

    <TableRow >
     <TextView android:id="@+id/commPwd" android:text="@string/commPWD" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     <EditText android:id="@+id/commPwdET" android:text="" android:password="true" style="@style/StyleEditText1" mce_style="@style/StyleEditText1"/>
    </TableRow>
   </TableLayout>
  </LinearLayout>

  <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">

    <LinearLayout android:id="@+id/linearLayoutTab1" android:layout_height="wrap_content"
     android:layout_width="fill_parent" android:orientation="horizontal">

     <LinearLayout android:id="@+id/linearLayoutTab2" android:layout_height="wrap_content"
      android:layout_width="fill_parent" android:orientation="horizontal" android:layout_weight="1">
      <CheckBox android:id="@+id/recordAcc"  android:layout_width="wrap_content" android:layout_height="wrap_content"/>
      <TextView android:id="@+id/commPwd" android:text="@string/saveUserAcc" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     </LinearLayout> 
     <LinearLayout android:id="@+id/linearLayoutTab2" android:layout_height="wrap_content"
      android:layout_width="fill_parent" android:orientation="horizontal" android:layout_weight="1">

      <CheckBox android:id="@+id/hideAcc" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
      <TextView android:id="@+id/commPwd" android:text="@string/ycUserAcc" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>
     </LinearLayout>  
    </LinearLayout>

   <LinearLayout android:id="@+id/linearLayoutTab1" android:layout_height="wrap_content"
     android:layout_width="fill_parent" android:orientation="horizontal">

     <LinearLayout android:layout_width="220px" android:layout_height="wrap_content" android:orientation="horizontal"
      android:gravity="center">

              <Button android:id="@+id/confirmexch" android:gravity="center" android:layout_width="wrap_content" 
         android:layout_height="50px" android:textSize="22dp" android:text="@string/login" android:layout_weight="1"
         android:focusable="false" android:textColor="@color/white" android:background="@drawable/buttonl"/>
     </LinearLayout>

     <LinearLayout android:id="@+id/linearLayoutTab" android:layout_height="wrap_content"
      android:layout_width="fill_parent" android:gravity="center">
      <ImageView android:layout_width="wrap_content" android:layout_height="50px" android:id="@+id/myImage"/>
     </LinearLayout>
  </LinearLayout>
 </LinearLayout>
 </LinearLayout>
</ScrollView>
app_bottom.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/appbottom" android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:layout_alignParentBottom="true"
  xmlns:android="http://schemas.android.com/apk/res/android">

 <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:background="@drawable/light">
  <ImageView  android:id="@+id/about" android:layout_width="30px" android:layout_height="wrap_content" android:src="@drawable/ttt"
    android:layout_alignParentLeft="true"/>
  <TextView android:id="@+id/light" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@color/black"/>
 </LinearLayout>

 <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
  android:layout_height="wrap_content" android:background="@drawable/mainmenu">
  <Button android:id="@+id/quotButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>

  <Button android:id="@+id/entrustButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>
  <Button android:id="@+id/queryButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>

  <Button android:id="@+id/yinZhengButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>

  <Button android:id="@+id/recordButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>

  <Button android:id="@+id/logoutButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"
   android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>
 </LinearLayout>
</LinearLayout>
tradelogin_portrait.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" style="@style/StyleLayoutMain" mce_style="@style/StyleLayoutMain"
 xmlns:android="http://schemas.android.com/apk/res/android">

 <!-- include RelativeLayout , android:layout_alignParentBottom, -->
 <!-- include id (android:id), layout id , layout include
   id-->
 <!-- include , xml , , 。 ,
   id。 include , include include id -->
 <include android:id="@id/titleLayout" layout="@layout/app_title" />
 <include layout="@layout/app_tradelogin"/>

 <include layout="@layout/app_bottom"/>

</RelativeLayout>
효 과 는 다음 과 같 습 니 다.

좋은 웹페이지 즐겨찾기