I've set app view on XML based layout:
setContentView(R.layout.mlayout);
with some views objects on it. Then, I added another view via:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.game);
layout.addView(new GamePanel(this));
Where GamePanel class head looks like this:
public class GamePanel extends SurfaceView implements SurfaceHolder.Callback
I've created a view object programmatically in GamePanel class, and tried to set it's X to its pos.X + 1 on each update. From logcat, the X is really changing to X+1 on each update, but on mobile screen the object is still on the same place (it didn't moved nor a bit; it's still on the place where it was placed first during creating). Why it doesn't move?
Draw method in GamePanel:
@Override
public void draw(Canvas canvas)
{
if (canvas!=null)
{
final int savedState = canvas.save();
if (objects != null)
{
for (Object o: objects)
{
o.draw(canvas);
}
}
canvas.restoreToCount(savedState);
}