here is the code-
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) searchPin.getLayoutParams();
params.setMargins(135, 176, 0, 0);
//params.leftMargin = 135; // also not worked
//params.topMargin = 376;
searchPin.setLayoutParams(params);
Where ever, from xml its working-
android:layout_marginLeft="135dp"
what can be the reason? am i missing something!
-thnx
I had a FrameLayout child of a RelativeLayout so the framework was trying to cast FrameLayout params to RelativeLayout, I solved this way
simple solution-
I think what you're missing is that, when you set programmatically the parameters for an element, those parameters are provided actually to the parent View, so that it knows how to position the element. The parameters are not set back to the element itself. Consider the following code example. Also note, that the layout parameters are of the type of the parent.
You can try this
Just use LayoutParams instead of FrameLayout.LayoutParams
this worked for me
Try this: