title: How to add scrollable horizontal Linearlayout inside scrollview dynamically
body: <p>I'm trying to implement an scrollable horizontal Linearlayout inside scrollview in a method dynamically , but the view (LinearLayout) does not scroll!</p>
  
  <p>This method get some result from server and then create the view dynamically. "layout_services" is an vertical LinearLayout which is implemented inside xml file.</p>
  
  <p>Voila the code : </p>
  
  <pre><code> for (ServiceResult serviceResult : response.getResult()) {
          LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(
                  ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          textViewParams.setMargins(15, 15, 15, 15);
          textViewParams.gravity = Gravity.RIGHT;
          TextView textView = new TextView(getActivity());
          textView.setPadding(5, 5, 5, 5);
          textView.setText(serviceResult.getCategory());
          textView.setLayoutParams(textViewParams);
          textView.setTextColor(Color.WHITE);
          textView.setBackgroundColor(Color.LTGRAY);
          if (!serviceResult.getServices().isEmpty()) {
              layout_services.addView(textView);
              LinearLayout.LayoutParams scrollLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
              ScrollView scrollView = new ScrollView(getActivity());
              scrollView.setLayoutParams(scrollLayoutParams);
              LinearLayout linearLayout = new LinearLayout(getActivity());
              linearLayout.setPadding(5, 5, 5, 5);
              LinearLayout.LayoutParams horizontalLayoutParams =
                      new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                              ViewGroup.LayoutParams.WRAP_CONTENT);
              horizontalLayoutParams.gravity = Gravity.RIGHT;
              linearLayout.setOrientation(LinearLayout.HORIZONTAL);
              linearLayout.setLayoutParams(horizontalLayoutParams);
              scrollView.addView(linearLayout);
              for (int i = 0; i &lt; serviceResult.getServices().size(); i++) {
                  int finalI = i;
                  Button btn = new Button(getActivity());
                  btn.setText(serviceResult.getServices().get(finalI).getName());
                  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(300, 200);
                  params.setMargins(15, 15, 15, 15);
                  params.gravity = Gravity.LEFT;
                  btn.setLayoutParams(params);
                  btn.setTextColor(Color.BLACK);
                  btn.setOnClickListener(view -&gt; {
                  });
                  linearLayout.addView(btn);
              }
              layout_services.addView(scrollView);
          }
      }
  </code></pre>