You can combine the attributes of the orientation and size of the resource objects , for example:
res/layout/ -- default
res/layout-port/ -- portrait for any screen size
res/layout-xlarge/ -- any orientation on xlarge screens
res/layout-xlarge-land/ -- landscape on xlarge screens
Use the directory layout-portfor your portraits only for smaller screen sizes, and then add xlarge layouts to the directory layout-xlargeif you want to use the same layout file for portrait and landscape on xlarge or layout-xlarge-landand layout-xlarge-portif you need different layout files depending on orientation.
, , , , , , Resources.NotFoundException. , Activity.setRequestedOrientation():
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.titlescreen);
} catch (Resources.NotFoundException e) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
return;
}
[...]
}
, , , setRequestedOrientation() .