简体   繁体   中英

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.

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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