I have this view
<ScrollView ...>
<RelativeLayout ...>
I define the RelativeLayout, one that I want to manipulate in Java, like this
ViewGroup parent = (ViewGroup) rootView
.findViewById(R.id.rltv_layout);
I want to change the Relative's height, so I figured I'd use
RelativeLayout.LayoutParams lpp = (RelativeLayout.LayoutParams) parent.getLayoutParams();
lpp.height = lpp.height + someHeights;
parent.setLayoutParams(lp);
Then error happened, LogCat said
05-18 14:01:49.829: E/AndroidRuntime(12856): java.lang.ClassCastException:
android.widget.FrameLayout$LayoutParams cannot be cast
to android.widget.RelativeLayout$LayoutParams
So I changed it to
FrameLayout.LayoutParams lpp = (FrameLayout.LayoutParams) parent.getLayoutParams();
Then error happened, LogCat said
05-18 14:06:16.297: E/AndroidRuntime(13183): java.lang.ClassCastException:
android.widget.RelativeLayout$LayoutParams cannot be cast
to android.widget.FrameLayout$LayoutParams
So what is it that it wants?
Also, AFAIK, LayoutParams type depended on its parent's type, not the View itself. At one point I tried ScrollView.LayoutParams
and still got same error.