Establecer parámetros de diseño mediante programación

I'm trying to add a scroll view inside another scroll view.

It should look like is this:

scroll view
  linear layout
   myprogramaticscroll view
    myprogramticlinear layout

     end button
    end layout
   end scroll
  end linear
end scroll

I'm trying to add scroll views inside of that. It goes in there, but I need to know how to set parameters correctly so I can see the whole button I have inside of my scroll view. I only see part of it, and I need to set the programatic linear layout and scroll view's width height and id. How do I do this? This is what I have so far:

    //the layout I'm putting my scrollview/linearlayout/button in
    LinearLayout l = (LinearLayout) findViewById(;

    ScrollView scroll = new ScrollView(this);
    LinearLayout nl = new LinearLayout(this);

    ImageButton yourButton = new ImageButton(this);



preguntado el 10 de marzo de 12 a las 01:03

2 Respuestas

You CAN'T put a scroll view inside another scroll view, that behavior would be odd, and Android would not know how to handle your scroll on the views.

For setting layout parameters, take a look at ViewGroup.LayoutParams, there're actually quite a few subclasses of ViewGroup.LayoutParams, which are for setting layout parameters for different kinds of layouts.

respondido 10 mar '12, 01:03

You can use a Scrollview in an another Scrollview. But this is not suggestible. It will be an issue to both the user and android OS. It will leads to Memory issues and also touch issues while scrolling the views. If you are expecting the Two scrolls (Horizontal and Vertical) at a time, then it is preferble to go for TwoDSCrollView

If you want to set the Layoutparams you should look at ViewGroup.LayoutParams.

If you want to set width and height then no need to set the Layoutparams. You can get the existing params by using getLayoutParams() for the view and set width and height to that params.

If you want to place vertical in vertical scroll or horizontal in horizontal scrollview the you should set the height of the internal scrollview height to the actual height of the total childs.

respondido 10 mar '12, 03:03

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