开发者

Custom layout who's size is screen size

开发者 https://www.devze.com 2023-02-14 10:04 出处:网络
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 a

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 ea开发者_开发问答ch layout can fit perfectly inside the screen.

How can I approach getting and setting the proper dimensions on the custom layout view?

Thanks!

-Jona


Override onSizeChanged in your custom View:

@Override 
protected void onSizeChanged(int width, int height, int oldw, int oldh) {
  //do some calculations with width and height
}
0

精彩评论

暂无评论...
验证码 换一张
取 消