trying to load object on page based on screen height
<p>i am playing around trying to make what i thought would be an easy game. i have been following someones tutorials and now i am trying to tweak it and make it do what i want. however i cannot find any answer that works for me they all come up with some error that stops it from compiling. the line in the code is</p>

<pre><code>droid = new Droid(BitmapFactory.decodeResource(getResources(),
    R.drawable.droid_1), 50, 50);
</code></pre>

<p>i can change the 2nd "50" to any hard coded number and it will move, however i always want it to create on the bottom of the screen reguardless of screen size. so basically i want 50 to be (screenheight - bitmapheight) here is the page of code i am working in.</p>

<pre class="lang-java prettyprint-override"><code>import net.obviam.droidz.model.Droid;
import net.obviam.droidz.model.components.Speed;
import android.app.Activity;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;


/**
 * This is the main surface that handles the ontouch events and draws
 * the image to the screen.
*/
public class MainGamePanel extends SurfaceView implements
    SurfaceHolder.Callback {

private static final String TAG = MainGamePanel.class.getSimpleName();

private MainThread thread;
private Droid droid;

public MainGamePanel(Context context) {
    super(context);
    // adding the callback (this) to the surface holder to intercept events
    getHolder().addCallback(this);

    // create droid and load bitmap
      droid = new Droid(BitmapFactory.decodeResource(getResources(), R.drawable.droid_1), 50, 50);

    // create the game loop thread
    thread = new MainThread(getHolder(), this);

    // make the GamePanel focusable so it can handle events
    setFocusable(true);


}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {
}

@Override
public void surfaceCreated(SurfaceHolder holder) {
    // at this point the surface is created and
    // we can safely start the game loop
    thread.setRunning(true);
    thread.start();
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
    Log.d(TAG, "Surface is being destroyed");
    // tell the thread to shut down and wait for it to finish
    // this is a clean shutdown
    boolean retry = true;
    while (retry) {
        try {
            thread.join();
            retry = false;
        } catch (InterruptedException e) {
            // try again shutting down the thread
        }
    }
    Log.d(TAG, "Thread was shut down cleanly");
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        // delegating event handling to the droid
        droid.handleActionDown((int)event.getX(), (int)event.getY());

        // check if in the lower part of the screen we exit
        if (event.getX() &gt; getWidth() /2) {
            thread.setRunning(false);
            ((Activity)getContext()).finish();

        } else {

            droid.setX((int)event.getX());
            droid.setY((int)event.getY());

        }

    } if (event.getAction() == MotionEvent.ACTION_MOVE) {
        // the gestures
        if (droid.isTouched()) {
            // the droid was picked up and is being dragged
            droid.setX((int)event.getX());
            droid.setY((int)event.getY());
        }
    } if (event.getAction() == MotionEvent.ACTION_UP) {
        // touch was released
        if (droid.isTouched()) {
            droid.setTouched(false);
        }
    }


    return true;
}

public void render(Canvas canvas) {
    canvas.drawColor(Color.BLACK);
    droid.draw(canvas);
}

/**
 * This is the game update method. It iterates through all the objects
 * and calls their update method if they have one or calls specific
 * engine's update method.
 */
public void update() {
    // check collision with right wall if heading right
    if (droid.getSpeed().getxDirection() == Speed.DIRECTION_RIGHT
            &amp;&amp; droid.getX() + droid.getBitmap().getWidth() / 2 &gt;= getWidth()) {
        droid.getSpeed().toggleXDirection();
    }
    // check collision with left wall if heading left
    if (droid.getSpeed().getxDirection() == Speed.DIRECTION_LEFT
            &amp;&amp; droid.getX() - droid.getBitmap().getWidth() / 2 &lt;= 0) {
        droid.getSpeed().toggleXDirection();
    }
    // check collision with bottom wall if heading down
    if (droid.getSpeed().getyDirection() == Speed.DIRECTION_DOWN
            &amp;&amp; droid.getY() + droid.getBitmap().getHeight() / 2 + 2 &gt;= getHeight()) {
        droid.getSpeed().toggleYDirection();
    }
    // check collision with top wall if heading up
    if (droid.getSpeed().getyDirection() == Speed.DIRECTION_UP
            &amp;&amp; droid.getY() - droid.getBitmap().getHeight() / 2 - 2 &lt;= 0) {
        droid.getSpeed().toggleYDirection();
    }
    // Update the lone droid
    droid.update();
}
</code></pre>

<p>}</p>
