Possible Duplicate:
Set margins in a LinearLayout programmatically
I have bunch of widgets in my layout.I have set layout_marginTop in layout file but I want to call these two buttons in activity and set layout_marginLeft and change the value programmatically.i tried with getLayoutParams() but can not set margin. is it possible to change margin of widgets declared in xml file programmatically(after calling layout in the activity)?
//oncreate method
setContentView(R.layout.gamelayout);
//xml layout
<ImageView
android:id="@+id/gameImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</ImageView>
<Button
android:id="@+id/lButton"
android:layout_width="wrap_content"
android:layout_height="140dip"
android:layout_marginTop="10dip"
android:layout_gravity="center_vertical|center_horizontal" />
<Button
android:id="@+id/rButton"
android:layout_width="wrap_content"
android:layout_height="140dip"
android:layout_marginTop="10dip"
android:layout_gravity="center_vertical|center_horizontal" />
<ImageView
android:id="@+id/levelImage"
android:layout_width="60dip"
android:layout_height="60dip"
android:layout_gravity="bottom|left"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/homeButton"
android:layout_width="60dip"
android:layout_height="60dip"
android:layout_gravity="bottom|right"
android:background="@drawable/home_btn" />
</FrameLayout>
please help me
thank you