In an Android application I need to add a view to my RelativeLayout that obeys the following rules:
It should look like this (the square should be centered vertically):
+-------------+
| activity |
| |
|+-----------+|
|| ||
|| square ||
|| ||
|| ||
|+-----------+|
| |
| |
+-------------+
In the end I want to have an ImageView that displays a quadratic image. Currently I did this by setting both width and height of the view to FILL_PARENT, and let the ImageView draw the image correctly (using scaleType=centerInside).
But: Now I want to have an additional view that is aligned with the top line of the square view, and this is where my approach fails. If I now set the width of the view to FILL_PARENT and the height of it to WRAP_CONTENT, the image will not fit the whole width any longer.
Do you have a solution to this problem? It would be preferrable if this could be done by just writing XML, if possible.
Thanks in advance!
Look at the top answer on this question.
Android layout with square buttons
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With