i have a relative layout on which i am displaying a page and some content. when i zoom my page...the layout size is not increasing. i want my layout to increase its size dyn
You can do it this way. I also added setting of the margins:
RelativeLayout targetItem = (RelativeLayout) findViewById(R.id.RelativeLayout01);
RelativeLayout.LayoutParams adaptLayout = new RelativeLayout.LayoutParams(mWidth, mHeight);
adaptLayout.setMargins(marginLeft, marginTop, marginRight, marginBottom);
targetItem.setLayoutParams(adaptLayout);
For mWidth and mHeight you also may set dip
values to make it adapt to the different screen sizes. Easy way to do that is to define Dimension in your strings.xml
and work with them, not with absolute values.
So, if you define relative_width
as 120dip, and relative_height
as 100 dip then in code you have
RelativeLayout.LayoutParams adaptLayout = new RelativeLayout.LayoutParams(getResources().getDimension(R.dimen.relative_width), getResources().getDimension(R.dimen.relative_height));