简体   繁体   English

更改主屏幕小部件内的视图高度

[英]Change height of view inside home screen widget

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.我对 Android 中的小部件非常陌生,我正在努力寻找一种方法来调整小部件内部视图的大小。 I´m trying to create like a volume chart where I add imageviews to a linear layout.我正在尝试像体积图表一样创建,我将图像视图添加到线性布局。 Is this even possible?这甚至可能吗? Thanks谢谢

You can change the layout height dynamically to say, x by using您可以动态更改布局高度,例如使用 x

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

This post I found can help you to get more input, to solve your problem.我发现的这篇文章可以帮助您获得更多输入,以解决您的问题。

I found a work around by setting the top padding to reduce the height.我通过设置顶部填充以降低高度找到了解决方法。 They always start at maximum height他们总是从最大高度开始

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM