title: How to allign Android imageView and textView in one line programmatically
body: <p>I'm pulling some data from DB, and need to display it in form of bullet-ed list.</p>
  
  <p>With the code:</p>
  
  <pre><code>for (int i=0; i&lt;ingredcount; i++){
              String ingredient = recipe.Ingredients.get(i);
              View linearlayout = findViewById(R.id.llIngredients);
              ImageView img = new ImageView(RecipeIngredientsDisplay.this);
              TextView txt1 = new TextView(RecipeIngredientsDisplay.this);
              LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              llp.setMargins(30, 2, 15, 2);
              LinearLayout.LayoutParams llp2 = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              llp2.setMargins(10, 2, 15, 2);
  
              img.setLayoutParams(llp2);
              img.setImageResource(R.drawable.dot_purple);
              txt1.setLayoutParams(llp);
  
              txt1.setText(ingredient);
              ((LinearLayout)linearlayout).addView(img);
              ((LinearLayout) linearlayout).addView(txt1);
  
          }
  </code></pre>
  
  <p>I have all the data correctly displayed, it's just that my image is in new line, and text is bellow it.</p>
  
  <p>So I'd like to programmatically set weight to my image and my text, so that they are both in one line.</p>
  
  <p>Usually I do this using adapter and inflating listView, but combination of scrollView and ListView within ScrollView does not behave good, and focus is lost when I have lot of ingredients. </p>