I am trying to position a TextView and an ImageView within a LinearLayout programmatically. The problem is that the textview is always on top of the imageview, and I would like to it be underneath. I cannot find a way to imitate the android:layout_below= xml attribute in the java UI approach.
Add a comment
|
2 Answers
LinearLayout lin = new LinearLayout(context);
lin.setOrientation(LinearLayout.VERTICAL);
ImageView imageView = new ImageView(context);
TextView textView = new TextView(context);
lin.addView(imageView);
lin.addView(textView);
the first component ImageView should be placed in the LinearLayout first, before the TextView.
Edit: oops forgot about "programmatically"