Adding a view to a LinearLayout at a specified position

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

I have the following main.xml file with a LinearLayout




        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 10:23

    To get position of view in a view group

                    val targetPosition = oldLL.indexOfChild(viewToAdd)
    

    To add a view at a position in a view group

                    newLL.addView(viewToAdd,targetPosition)
    

提交回复
热议问题