Android中資源文件用法簡單示例
本文實例講述了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" />
注意引用本地資源的文件的時候都加了android這個前綴。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》、《Android文件操作技巧匯總》、《Android操作SQLite數(shù)據(jù)庫技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android開發(fā)入門與進階教程》、《Android視圖View技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
相關(guān)文章
Android基于Xposed修改微信運動步數(shù)實例
這篇文章主要介紹了Android基于Xposed修改微信運動步數(shù)實例,需要的朋友可以參考下2017-06-06Android基于AlarmManager實現(xiàn)用戶在線心跳功能示例
這篇文章主要介紹了Android基于AlarmManager實現(xiàn)用戶在線心跳功能,結(jié)合檢測用戶在線功能實例形式分析了AlarmManager全局定時器的功能、使用方法及相關(guān)注意事項,需要的朋友可以參考下2017-10-10Android編程設(shè)定activity進入和退出效果的方法
這篇文章主要介紹了Android編程設(shè)定activity進入和退出效果的方法,簡單分析了Android Activity進入與退出效果的實現(xiàn)原理及相關(guān)屬性設(shè)置技巧,需要的朋友可以參考下2017-07-07如何自己實現(xiàn)Android View Touch事件分發(fā)流程
這篇文章主要介紹了如何自己實現(xiàn)Android View Touch事件分發(fā)流程,幫助大家更好的理解和學習使用Android,感興趣的朋友可以了解下2021-03-03Android使用ItemTouchHelper實現(xiàn)側(cè)滑刪除和拖拽
這篇文章主要為大家詳細介紹了Android使用ItemTouchHelper實現(xiàn)側(cè)滑刪除和拖拽,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-08-08