In an Android application, I need to add a view to my RelativeLayout that obeys the following rules:
- The view should be quadratic, i.e. The height and width of the view must match.
- The view should fill out the entire WIDTH.
It should look like this (the square should be vertical):
+-------------+ | activity | | | |+-----------+| || || || square || || || || || |+-----------+| | | | | +-------------+
In the end, I want to have an ImageView that displays a quadratic image. I currently do this by setting the width and height of the view to FILL_PARENT and let ImageView draw the image correctly (using scaleType = centerInside).
But: now I want to have an extra view that is aligned with the top line of the square view, and that is where my approach fails. If you now set the view width to FILL_PARENT and its height to WRAP_CONTENT, the image will no longer fit the entire width.
Do you have a solution to this problem? It would be preferable if this could be done simply by writing XML, if possible.
Thanks in advance!
mreichelt
source share