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
}
精彩评论