



下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Android標題欄添加控件及 Button控件背景顏色的設置、An droid中標題欄添加按現在很多的An droid程序都在標題欄上都顯示了一些按鈕和標題,如下圖:腸®崗屮Q O亨刑皿3個眈上一步選擇相片卡一步下面通過實例來看一下如何實現。1、在layout下創建一個titlebtn.xml文件,內容如下:<?xml version="1.0" encoding="utf-8" ?>vRelativeLayoutxm In s:a ndroid= " ndroid" an droid:layout_width
2、= "fill_pare nt"an droid:layout_height= "fill_pare nt"android:orientation= "horizontal" > vlmageButt onan droid:id= "+id/imageButto n1"an droid:layout_width= "wrap_c on te nt" an droid:layout_height= "wrap_c on te nt" an droid:layout_ali
3、g nPare ntLeft= "true" an droid:layout_ce nterVertical= "true" an droid:backgrou nd= "#00000000" android:src= "drawable/prv" /> <TextViewan droid:layout_width= "wrap_c on te nt" an droid:layout_height= "wrap_c on te nt" an droid:layou
4、t_ce nterl nPare nt= "true" an droid:text="標題欄"/> vlmageButt onan droid:id= "+id/imageButto n1"an droid:layout_width= "wrap_c on te nt" an droid:layout_height= "wrap_c on te nt"android:layout_alignParentRight= "true" android:layout_cente
5、rInParent= "true" android:background= "#00000000" android:src= "drawable/next" /></ RelativeLayout >在創建這個 xml 時需要 注意 :a)使用 RelativeLayout 的布局b)特別是右邊按鈕的屬性需要指定layout_ce nterl nPare nt從而有不同Button 控件背景顏色的設置 里我舉例如何使用selector,layer-list 完成 button 背景的層疊組合,情形下不同效果butto
6、n_ctrl.xml 中選擇器<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="<item android:state_pressed="true" android:drawable="drawable/button_highlight_ctrl" /><item android:drawable="drawable/button_normal_ctrl" /><
7、/selector>button_highlight_ctrl.xml 中兩層圖<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android=" <itemandroid:drawable="drawable/button_highlight_back"android:top="2dip"android:right="2dip"android:bottom="2dip"a
8、ndroid:left="2dip"/><item android:drawable="drawable/button_highlight_fore" android:top="2dip"android:right="2dip"android:bottom="2dip"android:left="2dip"/></layer-list>button_highlight_back.xml中完成背景顏色的漸變 <?xml version=&qu
9、ot;1.0" encoding="utf-8"?><shape xml ns:a ndroid=" ndroid"an droid:shape="recta ngle"><cor nersan droid:radius="4dip"/><gradie ntan droid:type="li near"an droid:a ngle="270"an droid:startColor="color/highlight_bu
10、tt on_ start_color"an droid:ce nterColor="color/highlight_butt on_ middle_color"an droid:e ndColor="color/highlight_butto n_en d_color"/></shape>button_highlight_fore是一張前景圖片,即按下時的頂部陰影:至此,已完成高亮butt on的制作,接下來是普通butt onbutton_ no rmal_ctrl.xml 中兩層圖<?xml version=&quo
11、t;1.0" encoding="utf-8"?><layer-list xml ns:a ndroid=" ndroid"><iteman droid:drawable="drawable/butt on_no rmal_back"an droid:top="2dip"an droid:right="2dip"an droid:bottom="2dip"an droid:left="2dip"/><iteman droid:drawable="drawable/butt on_no rmal_fore"an droid:top="2dip"an droid:right="2dip"an droid:bottom=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 新界東2025年數學四下期末復習檢測試題含解析
- 邢臺學院《有限元法原理與實踐》2023-2024學年第一學期期末試卷
- 2025至2031年中國硬質合金球形齒行業投資前景及策略咨詢研究報告
- 口腔頜面外科麻醉與鎮痛
- 甘肅省蘭州市聯片2024年中考數學押題卷含解析
- 廣東省東莞市中學堂星晨校2024屆中考聯考數學試卷含解析
- 2025公司主要負責人安全培訓考試試題及參考答案【培優A卷】
- 2025工廠職工安全培訓考試試題及參考答案【能力提升】
- 2025年承包商入廠安全培訓考試試題帶下載答案
- 2024-2025新職工入場安全培訓考試試題及答案ab卷
- GB/T 14614-1993小麥粉吸水量和面團揉和性能測定法粉質儀法
- 醬酒行業發展趨勢分析
- 《紅樓夢》賈府平面圖
- 養老機構全套服務管理流程圖()
- 運用PDCA辦法提高分級護理落實率
- 高級卒中中心申報操作流程
- 幼兒園幼兒小籃球活動體能測試表
- 遠盛水工重力壩輔助設計系統用戶使用手冊
- 通用城實景三維數據生產項目技術設計書
- 畢業設計(論文)-N402—1300型農用拖拉機履帶底盤的設計
- 巖棉項目申報書_參考模板
評論
0/150
提交評論