Another problem that you may encounter is that if you set parental alignment + wrap_content for your two children and your relative layout is wrap_content, and this relative layout is contained in LinearLayout full screen , your relative layout will occupy the entire width of LinearLayout.
If you do this with both “align parent left”, the relative layout will lie to the left, and its width will truly be “carry content”. But the behavior is different from "align parent right", which is a bit strange.
Workaround:
To solve this problem (I had to align one of the children on the right), I actually set the 2 children to “align the parent left” and play with the addition for the children, so that one of the children takes the upper position on the right corner. This is a dirty workaround, but the only thing I have found now.
Possible cleaner solutions:
Another trick would be to put 2 LinearLayout inside the FrameLayout, and then put your real children into each LinearLayout and play with LinearLayout's gravity to put the children in the right position.
- RelativeLayout
- Linearlayout
- LinearLayout (Gravity: Top Right)
Benjamin piette
source share