<RelativeLayout>
...
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:layout_marginTop=”11dp”
android:background=”@drawable/image” />
</RelativeLayout>
Then I need to set the Margin programmatically:
ImageView imageView = (ImageView) findViewRoot(R.id.imageView1);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
params.width = 100;
params.height = 100;
params.setMargins(0,0,0,0); //NOT WORK
imageView.setLayoutParams(params);
The ImageView still has marginLeft 10 and marginTop 11;
What is wrong?