Android開發(fā)之資源文件用法實(shí)例總結(jié)
本文實(shí)例總結(jié)了Android開發(fā)之資源文件用法。分享給大家供大家參考,具體如下:
這里記錄在Android開發(fā)中經(jīng)常用到的一些用法
arrays.xml定義數(shù)組
例:
<resources> <!-- share items --> <string-array name="app_share_items"> <item>新浪微博</item> <item>騰訊微博</item> </string-array> </resources>
純色圓角背景
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#4a90e2" /> <corners android:radius="95dp" /> </shape>
用法:
android:background="@drawable/xml_background_button_blue"
要獲取這種背景所對(duì)應(yīng)的類型為:Drawable:GradientDrawable,我們可以改變它的顏色,而保持背景不變。
顏色相關(guān)
ps中:0透明,1完全不透
android:顏色格式:argb alpha:[0,255] 完全透明到完全不透明
粉紅:#8f0f
uses-permission
彈窗口時(shí),在Manifest中添加:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
資源文件與類的對(duì)應(yīng)關(guān)系
selector對(duì)應(yīng)的是StateList
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/xml_login_button_press"/> <item android:drawable="@drawable/xml_login_button_normal"/> </selector>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <solid android:color="@color/pressed_color"/> </shape> </item> <item> <shape> <solid android:color="@color/transparent"/> </shape> </item> </selector>
shape 對(duì)應(yīng)的是GradientDrawable
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#4a90e2" /> <corners android:radius="95dp" /> </shape>
Notification
1. Action與Activity關(guān)聯(lián)
以下兩步缺一不可
step1: 指定一個(gè)Action常量:
public static final String DOWNLOAD_MANAGER = "com.james.app.download";
step2:在對(duì)應(yīng)的Activity中指定對(duì)應(yīng)的IntentFilter
<intent-filter> <action android:name="com.james.app.download"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter>
2. Notification是通過(guò)Action來(lái)區(qū)別的,不是通過(guò)ID來(lái)區(qū)別的
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》《Android開發(fā)入門與進(jìn)階教程》、《Android控件用法總結(jié)》、《Android短信與電話操作技巧匯總》及《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
Android中創(chuàng)建對(duì)話框(確定取消對(duì)話框、單選對(duì)話框、多選對(duì)話框)實(shí)例代碼
這篇文章主要介紹了詳解Android中創(chuàng)建對(duì)話框(確定取消對(duì)話框、單選對(duì)話框、多選對(duì)話框)的相關(guān)資料,需要的朋友可以參考下2016-04-04Android實(shí)現(xiàn)購(gòu)物車功能
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)購(gòu)物車功能的具體方法 ,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-02-02Android仿360市場(chǎng)下載按鈕的實(shí)現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于利用Android實(shí)現(xiàn)360市場(chǎng)下載按鈕效果的方法,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),并在文末給出了源碼供大家下載,需要的朋友們下面跟著小編一起來(lái)學(xué)習(xí)學(xué)習(xí)吧。2017-05-05Android實(shí)現(xiàn)把文件存放在SDCard的方法
這篇文章主要介紹了Android實(shí)現(xiàn)把文件存放在SDCard的方法,涉及Android針對(duì)SDCard的讀寫技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09Android通知欄前臺(tái)服務(wù)的實(shí)現(xiàn)
這篇文章主要介紹了Android通知欄前臺(tái)服務(wù)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03Android開發(fā)學(xué)習(xí)筆記之通過(guò)API接口將LaTex數(shù)學(xué)函數(shù)表達(dá)式轉(zhuǎn)化為圖片形式
這篇文章主要介紹了Android開發(fā)學(xué)習(xí)筆記之通過(guò)API接口將LaTex數(shù)學(xué)函數(shù)表達(dá)式轉(zhuǎn)化為圖片形式的相關(guān)資料,需要的朋友可以參考下2015-11-11Android編程之SurfaceView實(shí)例詳解
這篇文章主要介紹了Android編程之SurfaceView用法,簡(jiǎn)要分析了View和SurfaceView的區(qū)別,并結(jié)合實(shí)例形式分析了SurfaceView的具體使用步驟與相關(guān)技巧,需要的朋友可以參考下2016-02-02