I am trying to set the size and position of an image (image2) on the
screen so that it is in the same position and size relative to the
background image (image1) it is on no matter the screen size. To do
this, I try to alter the layout parameters of image2 in my `onCreate`
method of my `Activity` class:

                RelativeLayout rl = (RelativeLayout) findViewById(R.id.rlGen);
                RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(
                                (image1.getWidth()) / 4, (image1.getHeight()) / 
4);
                params.leftMargin = (image1.getWidth()) / 2;
                params.topMargin = (image1.getHeight()) / 2;
                rl.addView(image2, params);

But when my app goes to this activity, I get an error that says the
application has stopped unexpectedly. Then I have to force close the
app. Why would this happen? Is there something I am missing? or is
there a better way to do this?

-- 
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

Reply via email to