ปรับปรุงประสิทธิภาพของเลย์เอาต์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลองใช้ Compose
Jetpack Compose เป็นชุดเครื่องมือ UI ที่แนะนำสำหรับ Android ดูวิธีทำงานกับเลย์เอาต์ใน Compose
เลย์เอาต์เป็นส่วนสำคัญของแอปพลิเคชัน Android ที่ส่งผลต่อประสบการณ์ของผู้ใช้โดยตรง หาก
ใช้งานไม่ดี เค้าโครงอาจทำให้แอปใช้หน่วยความจำมากและ UI ทำงานช้า Android
SDK มีเครื่องมือที่จะช่วยระบุปัญหาในประสิทธิภาพเลย์เอาต์ เอกสารนี้จะช่วยให้คุณสามารถใช้การเลื่อนที่ราบรื่นในอินเทอร์เฟซโดยใช้หน่วยความจำน้อยที่สุด
บทเรียน
- เพิ่มประสิทธิภาพลำดับชั้นของการออกแบบ
- ในลักษณะเดียวกับที่หน้าเว็บที่ซับซ้อนอาจทำให้เวลาในการโหลดช้าลง ลำดับชั้นเลย์เอาต์ที่ซับซ้อน
ก็อาจทำให้เกิดปัญหาด้านประสิทธิภาพได้เช่นกัน เอกสารประกอบนี้แสดงวิธีใช้เครื่องมือ SDK เพื่อ
ตรวจสอบเลย์เอาต์และค้นหาคอขวดด้านประสิทธิภาพ
- ใช้เลย์เอาต์ซ้ำด้วย <include>
- หาก UI ของแอปพลิเคชันใช้โครงสร้างเลย์เอาต์บางอย่างซ้ำในหลายที่ เอกสารนี้จะแสดงวิธีสร้างโครงสร้างเลย์เอาต์ที่มีประสิทธิภาพและนำกลับมาใช้ใหม่ได้ รวมถึงวิธีรวมโครงสร้างเลย์เอาต์เหล่านั้นไว้ในเลย์เอาต์ UI ที่เหมาะสม
- โหลดมุมมองตามต้องการ
- นอกเหนือจากการรวมคอมโพเนนต์เลย์เอาต์หนึ่งไว้ในเลย์เอาต์อื่นแล้ว คุณอาจต้องการ
ทำให้เลย์เอาต์ที่รวมอยู่แสดงเฉพาะเมื่อจำเป็นหลังจากที่กิจกรรมทำงานอยู่
เอกสารประกอบนี้แสดงวิธีปรับปรุงประสิทธิภาพการเริ่มต้นเลย์เอาต์โดยการโหลด
บางส่วนของเลย์เอาต์ตามต้องการ
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Improve layout performance\n\nTry the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to work with layouts in Compose. \n[Performance in Compose →](/jetpack/compose/performance) \n\nLayouts are a key part of Android applications that directly affect the user experience. If\nimplemented poorly, your layout can make your app memory-intensive with slow UIs. The Android\nSDK includes tools to help identify problems in your layout performance. With this documentation,\nyou can implement smooth scrolling interfaces with a minimal memory footprint.\n\nLessons\n-------\n\n**[Optimize layout hierarchies](/develop/ui/views/layout/improving-layouts/optimizing-layouts)**\n: In the same way that a complex web page can slow down load time, a complex layout hierarchy\n can also cause performance problems. This documentation shows how you can use SDK tools to\n inspect your layout and discover performance bottlenecks.\n\n**[Reuse layouts with \\\u003cinclude\\\u003e](/develop/ui/views/layout/improving-layouts/reusing-layouts)**\n: If your application UI repeats certain layout constructs in multiple places, this\n documentation shows you how to create efficient, reusable layout constructs and include them\n in the appropriate UI layouts.\n\n**[Load views on demand](/develop/ui/views/layout/improving-layouts/loading-ondemand)**\n: Beyond including one layout component within another layout, you might want to\n make the included layout visible only when it's needed after the activity is running.\n This documentation shows how you can improve your layout's initialization performance by loading\n portions of your layout on demand."]]