I want to set Max Height of RecylerView.I am able to set max height using below code.Below code makes height 60% of current screen.
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int a = (displaymetrics.heightPixels * 60) / 100;
recyclerview1.getLayoutParams().height = a;
But now problem is that, if it have no item then also its height is 60%. So I want to set its height 0 when no item in it.
I want to achieve something like this.
if(recyclerview's height > maxHeight)
then set recyclerview's height to maxHeight
else dont change the height of recyclerview.
How can i set it? Please help me, I am stuck with it