0

I´m pretty new to widgets in Android and I´m struggling a little to find a way to resize views inside of the widget. I´m trying to create like a volume chart where I add imageviews to a linear layout. Is this even possible? Thanks

  • It is not clear what are you trying to do. Please add an image of what you're trying to achieve + add your XML attempt to achieve it. – Hadas Apr 29 '21 at 10:27
  • https://imgur.com/a/m9MF7Al. You can see in this image at the bottom where the green/red candles are. It´s a linear layout that I add a lot of image views to (You can´t have view in widgets). I would like to have different height on these candles depending on volume value. There is no param.height when working with widgets. You have to use like views.setInt(R.id.img_test,"setBackgroundResource",R.drawable.volume_candle_border_price_down) I´m wondering if there is anything similar to adjust height of a view – Oscar Berggren Apr 30 '21 at 09:16

2 Answers2

0

You can change the layout height dynamically to say, x by using

getLayoutParams().height= x;
requestLayout(); or invalidate();

This post I found can help you to get more input, to solve your problem.

Ole Pannier
  • 3,208
  • 9
  • 22
  • 33
  • I need to dynamically change the height of a view so it can´t be done in the xml since views are being added to the linear layout in code. Watch image where the green/red candles are https://imgur.com/a/m9MF7Al – Oscar Berggren Apr 30 '21 at 09:17
  • I updated my answer. I think that could be interesting. Sorry for late response. :) – Ole Pannier Apr 30 '21 at 21:08
0

I found a work around by setting the top padding to reduce the height. They always start at maximum height