Reputation: 2629
I need to use specific xml-layouts based on screen resolution, not size. So, the first design is used for resolution <= 480x800, and the second - for resolution >= 480x800.
How is it done ?
update.
I've come up with
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
final int height = display.getHeight();
final int width = display.getWidth();
int leadingResolutionSize = Math.max(height, width);
if(leadingResolutionSize <= 800){
setContentView(R.layout.main);
}else if(leadingResolutionSize > 800 && leadingResolutionSize <= 1024){
setContentView(R.layout.main_1024_600);
}else if(leadingResolutionSize > 1024){
setContentView(R.layout.main_1280_800);
}
Do you think it's a good solution ?
Upvotes: 0
Views: 481
Reputation: 7646
layout
folder in your project contains xml files which can be designed defaultly for PORTRAIT
Mode(that is 480*800 in your case). If you want for LANDSCAPE
Mode.In the same way declare another folder named as layout-land
(that is 800*480) and store the layout xml files in that folder and modify those files based on your requirement.
Upvotes: 0