<LinearLayout xmlns:android="..."
android:layout_width="match_parent"
android:layout_height="match_parent"> <!-- 錯誤:match_parent -->
<TextView android:id="@+id/tv_content" ... />
<TextView android:id="@+id/tv_time" ... />
</LinearLayout>
layout_height="match_parent" 讓 Item 在 ListView 測量階段獲得「盡可能大」的高度建議,配合 wrap_content 的子 View 導致測量傳遞混亂,最終由最長文本決定整體高度。
<LinearLayout ...
android:layout_width="match_parent"
android:layout_height="wrap_content"> <!-- 正確:wrap_content -->
<TextView
android:id="@+id/tv_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end" />
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp" />
</LinearLayout>
wrap_content,讓 Item 高度由內容決定。maxLines + ellipsize="end" 防止無限撐高。layout_weight 分配寬度,保證時間區域不被擠壓。dp 值而非 match_parent。ViewHolder 的根 itemView 在 onCreateViewHolder 中 inflate 時,父容器傳 null 或 parent, false,根佈局高度同樣應為 wrap_content。