XML布局之路


XML布局存放在工程文件的res/layout目錄下。安卓和PC端的界面布局有用到。

常用的布局方式,線性布局:LinearLayout

                            表格布局:TableLayout

                             幀布局  :FrameLayou

                             絕對布局:AbsoluteLayout 

                             相對布局:RelativeLayout

 

 1 <LinearLayout
 2     xmlns=“http://域名/xWindow/layout”
 3     xmlns:amdroid="http:/域名/xWindow/android"
 4     android:layout_width="match_patent"
 5     android:layout_height="warp_parent
 6     android:paddingLeft="12dp"
 7     android:clickable="true"
 8     android:gravity="center_vertical">
 9 <ImageView
10     android:id="1"
11     android:layout_width="1"
12     android:layout_heigth="1"
13     android:style="RoundBackgroundStyle">
14 <HoverPressedBackgroundHandler
15     android:normal = "XXX.png"
16     android:hover = "XXX.png"
17     android:pressed = "XXX.png"/>
18 <HoverTipHandler android:TipText =  "1111"/>
19 <1BtnHandler/>
20 </ImageView>
21 <ImageView
22     android:id="2"
23     android:layout_width="2"
24     android:layout_heigth="2"
25     android:style="RoundBackgroundStyle">
26 <HoverPressedBackgroundHandler
27     android:normal = "XXX.png"
28     android:hover = "XXX.png"
29     android:pressed = "XXX.png"/>
30 <HoverTipHandler android:TipText =  "2222"/>
31 <2BtnHandler/>        
32 </ImageView>
33 </LinearLayout>

match_parent和warp_parent的區別是:match_parent是自動填滿和fill_parent的功能是一樣的,warp_parent是根據需要填充的內容的變化,來確定大小。

paddingLeft和layout_marginLeft的區別是:layout_marginLeft實在整個布局的左邊界,paddingLeft是布局里的左邊界距離。

代碼的14-17行是正常顯示,鼠標懸浮,以及點擊三態的顯示。

HoverTipHandler是鼠標進入后的懸浮顯示

<1BtnHandler>觸發上面的點擊事件,用這個handler來顯示次級菜單欄,或者說是,顯示另一個界面布局。這個handler可以繼承xViewHandler。重寫虛函數。

定義一個xView類型的指針, m_p = &m_pHostView->vIewAt<xView>("1"),根據id取出對象,然后,通過封裝好的SLOT_CONNECT(),將這個按鈕與槽函數綁定上。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM