Setting Layout Parameters Programmatically












0















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
myprogramticbutton

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(R.id.linearLayoutFavorites);

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

ImageButton yourButton = new ImageButton(this);

nl.addView(yourButton);
scroll.addView(nl);

l.addView(scroll);









share|improve this question





























    0















    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
    myprogramticbutton

    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(R.id.linearLayoutFavorites);

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

    ImageButton yourButton = new ImageButton(this);

    nl.addView(yourButton);
    scroll.addView(nl);

    l.addView(scroll);









    share|improve this question



























      0












      0








      0








      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
      myprogramticbutton

      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(R.id.linearLayoutFavorites);

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

      ImageButton yourButton = new ImageButton(this);

      nl.addView(yourButton);
      scroll.addView(nl);

      l.addView(scroll);









      share|improve this question
















      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
      myprogramticbutton

      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(R.id.linearLayoutFavorites);

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

      ImageButton yourButton = new ImageButton(this);

      nl.addView(yourButton);
      scroll.addView(nl);

      l.addView(scroll);






      java android






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 5:37









      Cœur

      19k9114155




      19k9114155










      asked Mar 10 '12 at 1:06









      MarcMarc

      1113




      1113
























          2 Answers
          2






          active

          oldest

          votes


















          0














          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.






          share|improve this answer































            0














            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.






            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9643019%2fsetting-layout-parameters-programmatically%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              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.






              share|improve this answer




























                0














                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.






                share|improve this answer


























                  0












                  0








                  0







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 10 '12 at 1:37









                  neevekneevek

                  9,00273963




                  9,00273963

























                      0














                      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.






                      share|improve this answer




























                        0














                        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.






                        share|improve this answer


























                          0












                          0








                          0







                          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.






                          share|improve this answer













                          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.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 10 '12 at 3:38









                          PavandroidPavandroid

                          1,35521227




                          1,35521227






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9643019%2fsetting-layout-parameters-programmatically%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Monofisismo

                              Angular Downloading a file using contenturl with Basic Authentication

                              Olmecas