in ManActivity onCreate() Ho creato un'istanza di una nuova vista e l'ho aggiunta tramite layout.addView all'attività. Se provo getX() o getY() per quella vista ottengo sempre 0.0.Visualizza getX() e getY() restituiscono 0.0 dopo che sono stati aggiunti all'attività
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RelativeLayout main = (RelativeLayout)findViewById(R.id.main);
RelativeLayout.LayoutParams squarePosition = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
GameToken square1 = new GameToken(this,GameToken.SQUARE, fieldHeight,fieldWidth);
squarePosition.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
squarePosition.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
main.addView(square1, squarePosition);
System.out.println(square1.getX()); //Prints '0.0'
System.out.println(square1.getY()); //Prints '0.0'
Questo funziona perfettamente, grazie mille :) – cyden