解析android中include標(biāo)簽的使用
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 是必須設(shè)置的,否則界面不規(guī)則,不設(shè)置android:layout_above本界面沒(méi)有滑動(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:
<?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標(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-->
<!-- 如果沒(méi)有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>
效果如下:
- Android抽象布局——include、merge 、ViewStub詳解
- Android編程之include文件的使用方法
- Android中使用include標(biāo)簽和merge標(biāo)簽重復(fù)使用布局
- android使用include調(diào)用內(nèi)部組件的方法
- Android開發(fā)之merge結(jié)合include優(yōu)化布局
- Android開發(fā)技巧之ViewStub控件惰性裝載
- 深入分析Android ViewStub的應(yīng)用詳解
- Android組件ViewStub基本使用方法詳解
- Android布局技巧之include、merge與ViewStub標(biāo)簽的巧用
相關(guān)文章
Android編程實(shí)現(xiàn)自動(dòng)檢測(cè)版本及自動(dòng)升級(jí)的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)自動(dòng)檢測(cè)版本及自動(dòng)升級(jí)的方法,涉及Android版本檢測(cè),匹配,下載及自動(dòng)安裝等技巧,需要的朋友可以參考下2016-01-01Android Studio導(dǎo)入jar包過(guò)程詳解
這篇文章主要介紹了Android Studio導(dǎo)入jar包過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-11-11Android自定義View實(shí)現(xiàn)繪制虛線的方法詳解
這篇文章主要給大家介紹了Android自定義View實(shí)現(xiàn)繪制虛線的方法,在繪制過(guò)程中走了一些彎路才實(shí)現(xiàn)了虛線的效果,所以想著總結(jié)分享出來(lái),方便有需要的朋友和自己在需要的時(shí)候參考學(xué)習(xí),下面來(lái)一起看看吧。2017-04-04Flutter 構(gòu)建一個(gè)常用的頁(yè)面框架
大多數(shù) App 中都會(huì)有底部導(dǎo)航欄,通過(guò)底部導(dǎo)航欄切換實(shí)現(xiàn)不同頁(yè)面之間的切換。在Flutter 中提供了 BottomNavigationBar組件實(shí)現(xiàn)底部導(dǎo)航。本篇介紹通過(guò) BottomNavigationBar和 IndexedStack構(gòu)建最為常見(jiàn)的 App 頁(yè)面框架。2021-05-05下載、編譯、運(yùn)行android 7.1系統(tǒng)詳解(ubuntu 16.0.4)
Android 7的系統(tǒng)版本新增的很多的新功能,本篇文章主要介紹了基于ubuntu 16.0.4環(huán)境的下載、編譯、運(yùn)行android 7.1系統(tǒng),有興趣的可以了解一下。2017-01-01分享Android中ExpandableListView控件使用教程
這篇文章主要介紹了Android中ExpandableListView控件使用教程,可以實(shí)現(xiàn)二級(jí)列表展示效果,需要的朋友可以參考下2015-12-12Android實(shí)現(xiàn)View滑動(dòng)的幾種方式
Android中的View類是所有UI控件的基類(Base class),也就是說(shuō)我們平時(shí)所有到的各種UI控件,比如Button、ImagView等等都繼承自View類。這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)View滑動(dòng)的幾種方式,需要的朋友可以參考下2016-04-04Android 自定義縮短Toast顯示時(shí)間的實(shí)例代碼
這篇文章主要介紹了Android 自定義縮短Toast顯示時(shí)間,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01