I haven't been able to find anything out there on aligning a widget from a RelativeLayout to a widget within a horizontal LinearLayout. Aligning from one layout to another is almost not even mentioned on the Internet. I thought my question might be easiest explained with a picture. Please pardon the crude drawing:
This really sums up what I'm trying to do. The green is a relative layout and the blue is a horizontal linear layout with each item having a width of 'match_parent' and a weight of '1' for equal distribution across the linear layout - the purpose of this is to take advantage of wider screens and landscape mode by expanding items B-E, the most important information in my application.
I have a statically-sized image (A) to the left of the linear layout. The linear layout is relatively-placed 5dp to the right of A. Items B-D have a rightMargin of 8dp for spacing. F is a pair of TextViews that are aligned to the start of A. G is a pair of TextViews that are aligned to the right of the screen.
What I want to do is:
- Align the right (end) of F with the right (end) of B.
- Align the left (start) of G with the left (start) of C.
- Have this maintain this relationship as the device is rotated into landscape mode.
I have tried aligning the alignEnd, alignToEnd, and alignRight of the relative layout widgets to the widgets in the linear layout, but Android Studio rejects that since they're not siblings in a RelativeLayout. I could do this programmatically and calculate it in a PreDrawListener (add width of A + 5dp + width of B), but I'd rather do it in the layout, if possible.
Is this possible? Thanks.
Aucun commentaire:
Enregistrer un commentaire