Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassCastException when adding LayoutParams

Tags:

android

Which class do I have to use, when setting the LayoutParams of my LinearLayout? The following two are not working:

  1. linLayout.setLayoutParams(new ViewGroup.LayoutParams(50,50));
  2. linLayout.setLayoutParams(new android.widget.LinearLayout.LayoutParams(50,50));

if I get the params first, change them and set them back it's working. So I suppose the Params I get returned inherit from ViewGroup.LayoutParams...

Any idea? THX

like image 466
Frempe Avatar asked Jul 26 '11 12:07

Frempe


1 Answers

Use the LayoutParams of the parent. So in case your LinearLayout is a child of RelativeLayout then you use linLayout.setLayoutParams(new android.widget.RelativeLayout.LayoutParams(50,50));

like image 160
Daniel Novak Avatar answered Sep 18 '22 00:09

Daniel Novak