更新:不,不,這不是重複上述問題。感謝您的反對,但這個問題是關於每個項目被切斷。對不起,如果這不明確。如何在RecyclerView中設置項目的高度以適應所有元素?
我有RecyclerView.Adapter和Recycler視圖。
return new MyViewHolder(v);
問題是項目佈局中的最後一個元素被切斷了每個項目。只有一半的評級欄明星是可見的,所以我想增加物品的高度。該項目的佈局如下所示」
<FrameLayout
height=wrap_content
....
<RelativeLayout
height=match-parent
<ImageView
width=100dp
height=100dp
centerVertical=true >
<TextView
id=tv1
toTheEndOf="imageId"
toTheRightOf="imageId"
>
<TextView
id=tv2
below="tv1"
toStartOf="tv1"
>
<TextView
id=tv3
below=tv2"
<TextView id=tv4
below=tv3
<RatingBar // After adding tv3 only half of rating bar is shown?
below=tv4
height=wrap-content/>
<RelativeLayout>
</FrameLayout>
更新:切換的RelativeLayout爲wrap_content所示一切的結果,但現在TV2出現有時超過TV2有時是上面,但距離太近
的[RecyclerView被切斷的最後一個項目]可能的複製(https://stackoverflow.com/questions/32742724/recyclerview-is-cutting-off-the -last-item) – marmor
沒有@marmor它不是重複的,因爲它不是列表中的最後一個項目,它是項目中每個項目的最後一個元素。 – gitsensible