I have the following piece of code but the margins are not set.
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout android:id="@+id/MainLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
</LinearLayout>
setContentView(R.layout.main);
ImageView image1 = new ImageView(this);
image1.setImageResource(R.drawable.alien_256);
FrameLayout frl = (FrameLayout) this.findViewById(R.id.MainLayout01);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
params.leftMargin=50;
params.topMargin=40;
frl.addView(image1, params);
I have also tried using the params.setMargins(50, 40, 0, 0) but it
does not work either.
Any suggestion? (Absolute layout works just fine, too bad it was
deprecated)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---