I need to scale Relative Layout to size of device. Relative Layout have width = 2048 / height 6195.
Then in my activity I have width of device:
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
Constants.sDeviceWidth= size.x;
Then I create Relative layout. And after it I scale my view. 1)Count scale:
Float scale=(Constants.sDeviceWidth)/(float)newPage.getLayoutParams().width;
2) Set it:
newPage.setScaleX(scale);
newPage.setScaleY(scale);
3) Then I create parent view with red background for my relative layout:
RelativeLayout baseLayout=new RelativeLayout(context);
baseLayout.setLayoutParams(new RelativeLayout.LayoutParams((int) (pages.get(i).getLayoutParams().width * pages.get(i).getScaleX()), (int) (pages.get(i).getLayoutParams().height * pages.get(i).getScaleX())));
baseLayout.addView(pages.get(i));
baseLayout.setBackgroundColor(Color.RED);
where pages.get(i) is my child view which I scaled.
Then i found problem that for Nexus 7 all is ok but for Nexus 10 child view is to small. And I don`t know why. Nexus 10: 1
Nexus 7: 2