My root layout is a RelativeLayout, that contains some TextViews, Buttons and ImageViews. In the bottom part of the screen I have a TableLayout that represents a 4×4 grid of TextViews. I’d like to show a View (for example TextView) aligned to bottom right of each TextView in a grid.
so I have a
<TableLayout ...>
<TableRow ...>
<TextView android:id="@+id/x0y0".../>
<TextView android:id="@+id/x0y1".../>
....
</TableLayout>
...
<TextView android:layout_alignTop="@id/x0y0"
android:layout_alignLeft="@id/x0y0" ... />
<TextView android:layout_alignTop="@id/x1y1"
android:layout_alignLeft="@id/x1y1" ... />
but it’s located at the top left corner of the screen. I suspect that Views in a RelativeLayout can only be aligned to another views inside the same RelativeLayout, but I’d like this confirmed, or better, a suggestion on how to solve this issue.
Correct, relativelayout only can align its child nodes. You’ll need each cell in your table to contain a relative layout, pseudo-code:
You could also do this with vertical LinearLayout and gravity to right align the new View.