android getHeight () / getWidth con RelativeLayout
Hola, soy nuevo en Android y estoy enfrentando el problema: ¿cómo obtengo el alto / ancho de una vista, que se coloca en un diseño relativo? Intenté getHeight () y getWidth () y ambos devuelven 0.
Necesito saber si esta vista ha llegado al final del diseño para poder colocar la siguiente vista a su derecha o debajo de ella.
¿o tal vez hay una mejor manera de hacer esto sin conocer la posición de la vista actual?
edit: uso este código para crear un EditText y agregarlo al diseño:
EditText et1 = new EditText(context);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
p.addRule(RelativeLayout.RIGHT_OF,curView.getId());
et1.setLayoutParams(p);
et1.setId(loopid++);
curLayout.addView(et1);
curView=et1;
y luego llame a:
int[] location=new int[2];
curView.getLocationOnScreen(location);
Log.d("right:", String.valueOf(location[1]));
y muestra un 0.