Question

I am currently designing the widget for my app (see attached screenshot). Using a LinearLayout I was able to create the following setup:

  1. Image: weight - 2
  2. Title section: weight - 1
  3. Price section: weight -1

However I would like the title and price section to be of fixed height while the image's height changes (shrink or grow) when the user resizes the widget.

How can I make the height of the image dynamic without using layout_weight? Thank you

enter image description here

Was it helpful?

Solution

To achieve a resizable image section all I had to do was change the weight of the Image to 1 and set the actual height in dp for the title and price section.

UPDATE

A more efficient alternative is to use RealtiveLayout, this can be achieved by: 1. Having the price section having fixed height and aligned to parent bottom 2. Set the title section having fixed size and above the price 3. Set the image as match_parent height and above the title.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top