Is it possible to add dynamically add Fragments with LayoutParams? I have 2 fragments that I want to put in a RelativeLayout: one should lock to the left. The other should be locked to the right.
Is it possible to add dynamically add Fragments with LayoutParams? I have 2 fragments
Share
You could wrap them each in a layout (such as a
LinearLayout), then set its size and position. This answer is regarding a similar problem, and shows how to use aFrameLayoutwith custom layout parameters to contain aFragment.Note that, when using the
fragmentobject in XML, you can useandroid:layout_*attributes to control its position. Like so:However, I don’t think it’s possible to apply layout parameters programmatically to
Fragments. They’re notViewGroups, after all.