quest quest - 4 months ago 234
Android Question

How to set height of recyclerview programmatically?

I tried,

recyclerview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,100));


But its not working.

Answer

Try to set height like this,

ViewGroup.LayoutParams params=recyclerview.getLayoutParams();
params.height=100;
recyclerview.setLayoutParams(params);