資源類型總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本節中的每個頁面都會說明您可以在專案資源目錄 (res/
) 中提供的應用程式資源特定類型、格式和語法。
以下是各頁面的簡短摘要:
- 動畫資源
- 定義預先決定的動畫。
補間動畫會儲存在 res/anim/
中,並且從 R.anim
類別存取。
影格動畫會儲存在 res/drawable/
中,而且可從 R.drawable
類別存取。
- 顏色狀態清單資源
- 定義會根據檢視畫面狀態變更的顏色資源。
儲存在 res/color/
中,而且可從 R.color
類別存取。
- 可繪製資源
- 使用點陣圖或 XML 定義多種不同的圖形。
儲存在 res/drawable/
中,而且可從 R.drawable
類別存取。
- 版面配置資源
- 定義應用程式 UI 的版面配置。
儲存在 res/layout/
中,而且可從 R.layout
類別存取。
- 選單資源
- 定義應用程式選單的內容。
儲存在 res/menu/
中,而且可從 R.menu
類別存取。
- 字串資源
- 定義字串、字串陣列和複數 (並且包括字串格式和樣式)。
儲存在 res/values/
中,而且可從 R.string
、R.array
和 R.plurals
類別存取。
- 樣式資源
- 定義 UI 元素的外觀和格式。
儲存在 res/values/
中,而且可從 R.style
類別存取。
- 字型資源
- 定義字型系列,並且包含 XML 中的自訂字型。
儲存在 res/font/
中,而且可從 R.font
類別存取。
- 更多資源類型
- 將其他原始值定義為靜態資源,包括:
- Bool
- 包含布林值的 XML 資源。
- 顏色
- 包含顏色值 (十六進位顏色) 的 XML 資源,
- 維度
- 包含維度值的 XML 資源 (有測量單位)。
- ID
- XML 資源,可為應用程式資源和元件提供不重複 ID。
- 整數
- 包含整數值的 XML 資源。
- 整數陣列
- 提供整數陣列的 XML 資源。
- 型別陣列
- 提供
TypedArray
的 XML 資源 (可針對可繪項目的陣列使用)。
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-09-02 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]