Adding a view to a LinearLayout at a specified position

后端 未结 6 928
[愿得一人]
[愿得一人] 2020-12-25 09:52

I have the following main.xml file with a LinearLayout




        
6条回答
  •  别那么骄傲
    2020-12-25 10:30

    When adding a View to a ViewGroup, you can specify an index which sets the position of the view in the parent.

    You have two views and so (counting from zero) you would want to add at the 1st position; just call ll.addView(image, 1); to have it placed in between the two TextViews.

提交回复
热议问题