資源類型總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以在專案資源目錄 (res/
) 中提供特定類型的應用程式資源,本節中的各頁面會介紹這些類型的用法、格式和語法。
以下是各頁面的簡要介紹:
- 動畫資源
- 定義預先定義的動畫。
補間動畫會儲存在 res/anim/
中,並且可從 R.anim
類別存取。
影格動畫會儲存在 res/drawable/
中,而且可從 R.drawable
類別存取。
- 顏色狀態清單資源
- 定義會依據
View
狀態而變更的顏色資源。
儲存在 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
類別存取。
- 更多資源類型
- 將其他原始值定義為靜態資源,包括:
- 布林值
- 包含布林值的 XML 資源。
- 顏色
- 包含十六進位顏色值的 XML 資源。
- 尺寸
- 包含尺寸值與測量單位的 XML 資源。
- ID
- 為應用程式資源和元件提供專屬 ID 的 XML 資源。
- 整數
- 包含整數值的 XML 資源。
- 整數陣列
- 提供整數陣列的 XML 資源。
- 型別陣列
- 提供
TypedArray
(可用於可繪項目陣列) 的 XML 資源。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Resource types overview\n\nEach page in this section describes the usage, format, and syntax for a certain type\nof [app resource](/guide/topics/resources/providing-resources)\nthat you can provide in your project resources directory (`res/`).\n\nHere's a brief summary of each page:\n\n[Animation resources](/guide/topics/resources/animation-resource)\n: Define pre-determined animations. \n\n Tween animations are saved in `res/anim/` and accessed from the `R.anim` class. \n\n Frame animations are saved in `res/drawable/` and accessed from the `R.drawable` class.\n\n[Color state list resource](/guide/topics/resources/color-list-resource)\n: Define a color resource that changes based on the `View` state. \n\n Saved in `res/color/` and accessed from the `R.color` class.\n\n[Drawable resources](/guide/topics/resources/drawable-resource)\n: Define various graphics with bitmaps or XML. \n\n Saved in `res/drawable/` and accessed from the `R.drawable` class.\n\n[Layout resource](/guide/topics/resources/layout-resource)\n: Define the layout for your application UI. \n\n Saved in `res/layout/` and accessed from the `R.layout` class.\n\n[Menu resource](/guide/topics/resources/menu-resource)\n: Define the contents of your application menus. \n\n Saved in `res/menu/` and accessed from the `R.menu` class.\n\n[String resources](/guide/topics/resources/string-resource)\n: Define strings, string arrays, and plurals and include string formatting and styling. \n\n Saved in `res/values/` and accessed from the `R.string`, `R.array`,\n and `R.plurals` classes.\n\n[Style resource](/guide/topics/resources/style-resource)\n: Define the look and format for UI elements. \n\n Saved in `res/values/` and accessed from the `R.style` class.\n\n[Font resources](/guide/topics/resources/font-resource)\n: Define font families and include custom fonts in XML. \n\n Saved in `res/font/` and accessed from the `R.font` class.\n\n[More resource types](/guide/topics/resources/more-resources)\n: Define other primitive values as static resources, including the following:\n\n [Bool](/guide/topics/resources/more-resources#Bool)\n : XML resource that carries a boolean value.\n\n [Color](/guide/topics/resources/more-resources#Color)\n : XML resource that carries a hexadecimal color value.\n\n [Dimension](/guide/topics/resources/more-resources#Dimension)\n : XML resource that carries a dimension value with a unit of measure.\n\n [ID](/guide/topics/resources/more-resources#Id)\n : XML resource that provides a unique identifier for application resources and\n components.\n\n [Integer](/guide/topics/resources/more-resources#Integer)\n : XML resource that carries an integer value.\n\n [Integer array](/guide/topics/resources/more-resources#IntegerArray)\n : XML resource that provides an array of integers.\n\n [Typed array](/guide/topics/resources/more-resources#TypedArray)\n : XML resource that provides a [TypedArray](/reference/android/content/res/TypedArray), which you can use\n for an array of drawables."]]