LinearLayout/RelativeLayout/FrameLayout)。inflate(R.layout.xxx) 載入合併佈局(<merge> 根標籤)。findViewById 綁定內部子視圖。update() 等 API 更新狀態。ViewGroup,重寫 onMeasure()、onLayout()。MeasureSpec) 與位置,避免巢狀 LinearLayout 多次測量開銷。measureChildWithMargins()、getChildMeasureSpec() 協助計算。View(非 ViewGroup),完全自己繪製(onDraw(Canvas))。TextView/ImageView,改用 Canvas.drawText()、drawBitmap()。measure/layout 移至背景執行緒預先計算並快取。draw,消除滑動時的佈局計算掉幀。UIElement 框架)。「避免過早優化」。從 Composite View 開始,效能不足時逐層遷移。核心業務列表可考慮 Flat/Async,其他區域繼續用平台元件。
TweetCompositeView、TweetLayoutView、TweetElementView、AsyncTweetView。UIElement 框架:TextElement、ImageElement、LayoutInflater 等非 View 系統的平行實現。理解四層演進脈絡,即可根據專案複雜度選擇最適合的自定義佈局策略。