最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

解析android中include標(biāo)簽的使用

 更新時(shí)間:2013年06月15日 10:36:27   作者:  
本篇文章是對(duì)android中include標(biāo)簽的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
在一個(gè)項(xiàng)目中我們可能會(huì)需要用到相同的布局設(shè)計(jì),如果都寫在一個(gè)xml文件中,代碼顯得很冗余,并且可讀性也很差,所以我們可以把相同布局的代碼單獨(dú)寫成一個(gè)模塊,然后用到的時(shí)候可以通過<include /> 標(biāo)簽來重用layout代碼。
app_title.xml:
復(fù)制代碼 代碼如下:

<?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:
復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<!-- android:layout_below與 android:layout_above 是必須設(shè)置的,否則界面不規(guī)則,不設(shè)置android:layout_above本界面沒有滑動(dòng)效果-->
<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樣式,如果這里的屬性和樣式里定義的屬性重復(fù),則這里會(huì)替換樣式里定義的屬性-->
     <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:
復(fù)制代碼 代碼如下:

<?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:
復(fù)制代碼 代碼如下:

<?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標(biāo)簽內(nèi)不能設(shè)置RelativeLayout屬性,如android:layout_alignParentBottom,因?yàn)椴黄鹱饔?-->
 <!-- include標(biāo)簽內(nèi)設(shè)置id屬性后(android:id),其引用的布局layout內(nèi)的id屬性就不起作用了,懷疑是其引用的layout外層包裹了一層include標(biāo)簽
  或者是覆蓋了其內(nèi)的屬性id-->
 <!-- 如果沒有include標(biāo)簽,所有布局代碼都寫在一個(gè)xml文件中,界面會(huì)顯得很冗余,可讀性很差。而且界面加載的時(shí)候是按照順序加載的,前面的布局不能
  調(diào)用其后面的布局id。而采用include后,一個(gè)include中可以引用其后的include中的布局id屬性 -->
 <include android:id="@id/titleLayout" layout="@layout/app_title" />
 <include layout="@layout/app_tradelogin"/>

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

</RelativeLayout>

效果如下:

相關(guān)文章

  • Android開發(fā)手冊(cè)RatingBar星級(jí)評(píng)分控件實(shí)例

    Android開發(fā)手冊(cè)RatingBar星級(jí)評(píng)分控件實(shí)例

    這篇文章主要為大家介紹了Android開發(fā)手冊(cè)RatingBar星級(jí)評(píng)分控件實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-06-06
  • Android自定義照相機(jī)倒計(jì)時(shí)拍照

    Android自定義照相機(jī)倒計(jì)時(shí)拍照

    本文給大家介紹Android自定義照相機(jī),并且實(shí)現(xiàn)倒計(jì)時(shí)拍照功能,對(duì)android自定義照相機(jī)相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧
    2015-12-12
  • 淺談android組件化之ARouter簡(jiǎn)單使用

    淺談android組件化之ARouter簡(jiǎn)單使用

    本篇文章主要介紹了淺談android組件化之ARouter簡(jiǎn)單使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • Android自定義橫向滑動(dòng)菜單的實(shí)現(xiàn)

    Android自定義橫向滑動(dòng)菜單的實(shí)現(xiàn)

    這篇文章主要介紹了Android自定義橫向滑動(dòng)菜單的實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-05-05
  • Android開發(fā)之AAR文件的生成與使用步驟

    Android開發(fā)之AAR文件的生成與使用步驟

    Android中的aar主要是針對(duì)于Android Library而言的,可以簡(jiǎn)單的理解為是對(duì)Android Library的打包,這個(gè)包的格式為.aar,下面這篇文章主要給大家介紹了關(guān)于Android開發(fā)之AAR文件的生成與使用步驟的相關(guān)資料,需要的朋友可以參考下
    2022-07-07
  • Android 中三種啟用線程的方法總結(jié)

    Android 中三種啟用線程的方法總結(jié)

    下面小編就為大家?guī)硪黄狝ndroid 中三種啟用線程的方法總結(jié)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02
  • Android Studio實(shí)現(xiàn)簡(jiǎn)單計(jì)算器APP

    Android Studio實(shí)現(xiàn)簡(jiǎn)單計(jì)算器APP

    這篇文章主要為大家詳細(xì)介紹了Android Studio實(shí)現(xiàn)簡(jiǎn)單計(jì)算器APP,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-03-03
  • android非RxJava環(huán)境下使用Handler實(shí)現(xiàn)預(yù)加載

    android非RxJava環(huán)境下使用Handler實(shí)現(xiàn)預(yù)加載

    這篇文章主要介紹了android非RxJava環(huán)境下使用Handler實(shí)現(xiàn)預(yù)加載的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 開箱即用的Google與百度定位坐標(biāo)系轉(zhuǎn)換實(shí)例

    開箱即用的Google與百度定位坐標(biāo)系轉(zhuǎn)換實(shí)例

    這篇文章主要為大家介紹了開箱即用的Google與百度定位坐標(biāo)系轉(zhuǎn)換實(shí)例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • Android中Dialog對(duì)話框的使用小結(jié)

    Android中Dialog對(duì)話框的使用小結(jié)

    這篇文章主要給大家總結(jié)了一些關(guān)于Android中Dialog對(duì)話框的使用方法,這其中包括普通對(duì)話框、確定取消對(duì)話框、多按鈕對(duì)話框、列表對(duì)話框、帶Adapter的對(duì)話框、單選對(duì)話框以及多選對(duì)話框等,需要的朋友可以參考學(xué)習(xí),下面來一起看看詳細(xì)的介紹吧。
    2017-04-04

最新評(píng)論

巴南区| 通河县| 九江县| 固原市| 云安县| 湘西| 双鸭山市| 嘉荫县| 大新县| 昌平区| 兖州市| 翼城县| 封丘县| 万山特区| 肥东县| 京山县| 福泉市| 久治县| 翼城县| 桐乡市| 上虞市| 广东省| 神农架林区| 凯里市| 平昌县| 获嘉县| 武川县| 阿图什市| 郎溪县| 唐海县| 碌曲县| 邛崃市| 洪江市| 抚州市| 闽清县| 翼城县| 邛崃市| 新巴尔虎左旗| 瑞安市| 康保县| 自治县|