The height of the screen includes the title and the notification bar. Make the Activity Full Screen and remove the title will solve the issue. Try this:
PixelParticle...
public class PixelParticle extends View {
private float locationX;
private float locationY;
private int sizeX;
private int sizeY;
private Paint color;
private Rect rect;
private int paintcolor;
private float myLocX;
private float myLocY;
public PixelParticle(Context context, float locationX, float locationY,
int sizeX, int sizeY, int paintcolor) {
super(context);
this.locationX = locationX;
this.locationY = locationY;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.paintcolor = paintcolor;
rect = new Rect();
color = new Paint();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(myBitmap, 250, 250,
true);
canvas.drawBitmap(resizedBitmap, locationX
- (resizedBitmap.getWidth() / 2),
locationY - (resizedBitmap.getHeight() / 2), null);
}}
MainActivity..
public class MainActivity extends Activity {
private int pixelColor;
private float x;
private float y;
PixelParticle pp ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
x = event.getX();
y = event.getY();
pixelColor = Color.RED;
pp = new PixelParticle(this, x, y, 50, 50, pixelColor);
setContentView(pp);
return false;
}}