ภาพรวมประเภททรัพยากร
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แต่ละหน้าในส่วนนี้จะอธิบายการใช้งาน รูปแบบ และไวยากรณ์ของทรัพยากรแอปบางประเภทที่คุณระบุได้ในไดเรกทอรีทรัพยากรโปรเจ็กต์ (res/
)
สรุปสั้นๆ ของแต่ละหน้ามีดังนี้
- แหล่งข้อมูลภาพเคลื่อนไหว
- กำหนดภาพเคลื่อนไหวที่กำหนดไว้ล่วงหน้า
ระบบจะบันทึกภาพเคลื่อนไหวแบบ Tween ใน 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
- ประเภททรัพยากรเพิ่มเติม
- กำหนดค่าพื้นฐานอื่นๆ เป็นทรัพยากรแบบคงที่ ซึ่งรวมถึงค่าต่อไปนี้
- Bool
- ทรัพยากร XML ที่มีค่าบูลีน
- สี
- แหล่งข้อมูล XML ที่มีค่าสีฐานสิบหก
- มิติข้อมูล
- ทรัพยากร XML ที่มีค่ามิติข้อมูลพร้อมหน่วยวัด
- ID
- ทรัพยากร XML ที่ให้ตัวระบุที่ไม่ซ้ำกันสำหรับทรัพยากรและคอมโพเนนต์ของแอปพลิเคชัน
- จำนวนเต็ม
- ทรัพยากร XML ที่มีค่าจำนวนเต็ม
- อาร์เรย์จำนวนเต็ม
- แหล่งข้อมูล XML ที่ระบุอาร์เรย์ของจำนวนเต็ม
- อาร์เรย์ที่พิมพ์
- ทรัพยากร XML ที่มี
TypedArray
ซึ่งคุณใช้สำหรับอาร์เรย์ของ drawable ได้
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],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."]]