Android開發(fā)之資源文件用法實例總結(jié)
本文實例總結(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"
要獲取這種背景所對應(yīng)的類型為:Drawable:GradientDrawable,我們可以改變它的顏色,而保持背景不變。
顏色相關(guān)
ps中:0透明,1完全不透
android:顏色格式:argb alpha:[0,255] 完全透明到完全不透明
粉紅:#8f0f
uses-permission
彈窗口時,在Manifest中添加:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
資源文件與類的對應(yīng)關(guān)系
selector對應(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 對應(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: 指定一個Action常量:
public static final String DOWNLOAD_MANAGER = "com.james.app.download";
step2:在對應(yīng)的Activity中指定對應(yīng)的IntentFilter
<intent-filter> <action android:name="com.james.app.download"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter>
2. Notification是通過Action來區(qū)別的,不是通過ID來區(qū)別的
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》《Android開發(fā)入門與進階教程》、《Android控件用法總結(jié)》、《Android短信與電話操作技巧匯總》及《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》
希望本文所述對大家Android程序設(shè)計有所幫助。
相關(guān)文章
Android中創(chuàng)建對話框(確定取消對話框、單選對話框、多選對話框)實例代碼
這篇文章主要介紹了詳解Android中創(chuàng)建對話框(確定取消對話框、單選對話框、多選對話框)的相關(guān)資料,需要的朋友可以參考下2016-04-04Android實現(xiàn)把文件存放在SDCard的方法
這篇文章主要介紹了Android實現(xiàn)把文件存放在SDCard的方法,涉及Android針對SDCard的讀寫技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09Android開發(fā)學(xué)習(xí)筆記之通過API接口將LaTex數(shù)學(xué)函數(shù)表達式轉(zhuǎn)化為圖片形式
這篇文章主要介紹了Android開發(fā)學(xué)習(xí)筆記之通過API接口將LaTex數(shù)學(xué)函數(shù)表達式轉(zhuǎn)化為圖片形式的相關(guān)資料,需要的朋友可以參考下2015-11-11