android How to add view at start of layout?

后端 未结 3 1586
醉酒成梦
醉酒成梦 2020-12-11 14:43

My question is simple. I have a linearlayout. It has some child views. Now I want to add a view at the start of the child. Means in normal addView(view), the view s added at

相关标签:
3条回答
  • 2020-12-11 15:43

    Consider exploring the index argument of the addView method in parent class ViewGroup, Specifically addView(View child, ViewGroup.LayoutParams params). This method adds a View to the parent layout with the params defined, the index acts as a preference or rather point of insertion of the view in the layout.

    0 讨论(0)
  • 2020-12-11 15:45

    create a list of views, add your view to it and then add all views from layout to that list, remove all views from layout and add all views from your list

    0 讨论(0)
  • 2020-12-11 15:46

    Use addView (View child, int index) with index = 0

    0 讨论(0)
提交回复
热议问题