From your Logcat it looks like you are casting a ViewGroup.LayoutParams
class to a GridLayout.LayoutParams
. This is a common issue when you call the constructor method of LayoutParams
as you have:
albumLayout.setLayoutParams(new LayoutParams(100, 100));
You want to be specific with your LayoutParams
, so if you are using a GridLayout
, use GridLayout.LayoutParams
and for LinearLayout
use LinearLayout.LayoutParams
etc. This stops the wrong version being picked up as you always want to use the parent Class of your ViewGroup.
In the example above, albumLayout
is a GridLayout
, so you want to use GridLayout.LayoutParams
. Change that line to this:
albumLayout.setLayoutParams(new GridLayout.LayoutParams(100, 100));
You also have a couple of instances where you have LinearLayouts
and a RelativeLayout
that could do with the same change. (LinearLayout.LayoutParams
and RelativeLayout.LayoutParams
).