自訂 PopupWindow 內含 ListView(5 項),底部出現大片空白。Log 顯示 getView 被呼叫多次,懷疑是重複渲染導致。
measure 階段會多次呼叫 getView 取得子視圖測量高度,不等於實際渲染重複。<!-- 錯誤:外層 wrap_content,ListView 無法測量 -->
<LinearLayout android:layout_height="wrap_content">
<ListView android:layout_height="wrap_content" />
</LinearLayout>
<!-- 正確:外層固定高度或 match_parent,ListView match_parent -->
<LinearLayout android:layout_height="300dp">
<ListView android:layout_height="match_parent" />
</LinearLayout>