Get Actual Pixels in android
<p>I am overriding the SurfaceHolder like this and placing an image inside it.</p>

<pre><code>public class TestCameraActivity extends Activity implements SurfaceHolder.Callback
</code></pre>

<p>I want to get the <strong>x</strong> and <strong>y</strong> position of the this image. How to get it?
Please help.</p>

<p>This is the code:</p>

<pre><code>public class TestCameraActivity extends Activity implements SurfaceHolder.Callback {

Camera camera;
SurfaceView surfaceView;
SurfaceHolder surfaceHolder;
boolean previewing = false;
LayoutInflater controlInflater = null;
ImageView image;
Button b;
View viewControl;
RelativeLayout rel;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    getWindow().setFormat(PixelFormat.UNKNOWN);  
    surfaceView = (SurfaceView)findViewById(R.id.camerapreview);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    controlInflater = LayoutInflater.from(getBaseContext());
    viewControl = controlInflater.inflate(R.layout.control, null);

    image =(ImageView) viewControl.findViewById(R.id.img);

    LayoutParams layoutParamsControl = new LayoutParams(LayoutParams.FILL_PARENT, 
    LayoutParams.FILL_PARENT);
    this.addContentView(viewControl, layoutParamsControl);  
</code></pre>

<p>sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
        boolean accelSupported = sensorMgr.registerListener(this, SENSOR_ACCELEROMETER, SENSOR_DELAY_UI);
     }</p>

<pre><code>@Override
    public void onSensorChanged(int sensor, float[] values) {
        float x = values[0];
        float y = values[1];
        float z = values[2];    
        System.out.println("x = " + x + ", y = " + y + ",z = " + z);

        Rect r = image.getDrawable().getBounds();

        int drawLeft = r.left;
        int drawTop = r.top;
        int drawRight = r.right;
        int drawBottom = r.bottom;

        r.left = (int) x;
        r.right =(int) y;


    }
</code></pre>
