Agregar una vista a ScrollView

Tengo una clase que se extiende View. I want to add it to a ScrollView programmatically. I'm able to add it to a LinearLayout but have no success with a ScrollView. ¿Lo que da?

sv = (ScrollView)findViewById(;

myview = new MyViewClass(this);
myview.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));


preguntado el 24 de agosto de 12 a las 02:08

Are you calling setContentView(sv); ? -

no, I'm calling setContentView(R.layout.main) which contains the scrollview -

2 Respuestas

You can add your View to the ScrollView if its the only view in the ScrollView.

De lo contrario obtendrá ScrollView can have only 1 direct child excepción.

To add multiple Views to a ScrollView. First add a Linear or Relative Layout in the ScrollView and then add Views to this Layout.

Respondido 27 ago 12, 07:08

jsonUserInfo = actionObject.getUserInfoID(urlsId).getJSONArray("data").getJSONObject(i);
ModeUser userinf=new ModeUser();

respondido 28 mar '13, 14:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.