Android中資源文件用法簡(jiǎn)單示例
本文實(shí)例講述了Android中資源文件用法。分享給大家供大家參考,具體如下:
一、XML文件間資源文件的使用
引用格式:
attribute="@[packagename:]resourcetype/resourceidentifier"
example:
有strings.xml、color.xml、dimen.xml文件,使用其中的參數(shù)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="@dimen/standard_border"> <EditText android:id="@+id/myEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/stop_message" android:textColor="@color/opaque_blue" /> </LinearLayout>
二、使用系統(tǒng)的資源
使用android本地系統(tǒng)資源要這樣寫:
在XML文件中的使用方法:
<EditText android:id="@+id/myEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@android:string/httpErrorBadUrl" android:textColor="@android:color/darker_gray" />
注意引用本地資源的文件的時(shí)候都加了android這個(gè)前綴。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》、《Android文件操作技巧匯總》、《Android操作SQLite數(shù)據(jù)庫(kù)技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫(kù)操作技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android開發(fā)入門與進(jìn)階教程》、《Android視圖View技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
Android基于Xposed修改微信運(yùn)動(dòng)步數(shù)實(shí)例
這篇文章主要介紹了Android基于Xposed修改微信運(yùn)動(dòng)步數(shù)實(shí)例,需要的朋友可以參考下2017-06-06Android Studio 當(dāng)build時(shí)候出錯(cuò)解決辦法
這篇文章主要介紹了 Android Studio在build的時(shí)候出現(xiàn)transformClassesWithDexForDebug錯(cuò)誤解決辦法的相關(guān)資料,需要的朋友可以參考下2017-05-05Android基于AlarmManager實(shí)現(xiàn)用戶在線心跳功能示例
這篇文章主要介紹了Android基于AlarmManager實(shí)現(xiàn)用戶在線心跳功能,結(jié)合檢測(cè)用戶在線功能實(shí)例形式分析了AlarmManager全局定時(shí)器的功能、使用方法及相關(guān)注意事項(xiàng),需要的朋友可以參考下2017-10-10Android編程設(shè)定activity進(jìn)入和退出效果的方法
這篇文章主要介紹了Android編程設(shè)定activity進(jìn)入和退出效果的方法,簡(jiǎn)單分析了Android Activity進(jìn)入與退出效果的實(shí)現(xiàn)原理及相關(guān)屬性設(shè)置技巧,需要的朋友可以參考下2017-07-07如何自己實(shí)現(xiàn)Android View Touch事件分發(fā)流程
這篇文章主要介紹了如何自己實(shí)現(xiàn)Android View Touch事件分發(fā)流程,幫助大家更好的理解和學(xué)習(xí)使用Android,感興趣的朋友可以了解下2021-03-03Android使用ItemTouchHelper實(shí)現(xiàn)側(cè)滑刪除和拖拽
這篇文章主要為大家詳細(xì)介紹了Android使用ItemTouchHelper實(shí)現(xiàn)側(cè)滑刪除和拖拽,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-08-08Android自定義View實(shí)現(xiàn)公交成軌跡圖
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)公交成軌跡圖,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06