我遇到了一个问题,需要根据Recycler的总项目更改其高度。我尝试使用如下的Layout Param:
ViewGroup.LayoutParams params = myRecyclerView.getLayoutParams();
params.height = itemHeight * numberOfItem;
myRecyclerView.requestLayout();
或者 ViewGroup.LayoutParams params = new RecyclerView.LayoutParams(..WRAP_CONTENT, ...WRAP_CONTENT);;
params.height = itemHeight * numberOfItem;
myRecyclerView..setLayoutParams(params);
但是它没起作用。我该怎么办?请帮帮我!
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, heightInPixels, getResources().getDisplayMetrics());
- kushpf