I want to set Imageview and Textview on same line in LinearLayout but the Imageview is always higher than the Textview.
Here is my code:
String b[] = cacBuocThucHien.split("#");
for (int j = 0; j < b.length; j++) {
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(30,30);
    lp.setMargins(50, 0, 0, 0);
    ImageView img = new ImageView(RecipesDetailActivity.this);
    TextView tv = new TextView(RecipesDetailActivity.this);
    img.setLayoutParams(lp2);
    img.setImageResource(R.mipmap.testic);
    tv.setLayoutParams(lp);
    tv.setText(b[j] + "\n");
    layoutHuongDan.addView(img);
    layoutHuongDan.addView(tv);
}
 
     
     
     
     
     
    