[英]Custom layout who's size is screen size
I'm trying to create a custom layout that it automatically sets it's dimensions, height and width, according to the screen resolution. 我正在尝试创建一个自定义布局,它会根据屏幕分辨率自动设置尺寸,高度和宽度。 The reason I'm looking for such a behavior is that I want to add few of these custom layouts inside a HorizontalScrollView so that each layout can fit perfectly inside the screen. 我正在寻找这种行为的原因是,我想在HorizontalScrollView中添加这些自定义布局中的几个,以便每个布局都可以完美地适合屏幕内部。
How can I approach getting and setting the proper dimensions on the custom layout view? 如何在自定义布局视图上获取并设置适当的尺寸?
Thanks! 谢谢!
-Jona -乔纳
Override onSizeChanged in your custom View
: 在您的自定义View
覆盖onSizeChanged :
@Override
protected void onSizeChanged(int width, int height, int oldw, int oldh) {
//do some calculations with width and height
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.