There is an application, and I would like to add the ability to change the orientation, those loading another layout only by 10 ". As an option only by 10" +.

Is it possible to do something like that? If so, please tell me which method to use.

  • one
    specify, do you want to allow turning the eran, only on 10 "devices, or want to use a special landscape layout only on 10" devices? ъ - Vladyslav Matviienko
  • @metalurgus want to use a special landscape layout only on 10 "devices. - St. Ivan
  • @metalurgus sorry, a little confused himself. I want to allow turning the screen only on 10 "devices and at the same time using a special landscape layout. - St. Ivan

1 answer 1

For a 10 "+ 10-inch tablet use the modifier for resources -xlarge or -sw800 API 13+

You need to prohibit the change of orientation for all devices except:

Create a folder with resources similar to the values ​​for the example values-sw800 and values-xlarge, put the boolean flag there:

 <bool name="orientation_portrait">false</bool> 

When starting, insert a piece of code example:

 if(getResources().getBoolean(R.bool.orientation_portrait)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

It turns out that only at the start, the device 10 "+ it will be possible to change the orientation to land, otherwise only portrait. Do not forget only in default values, add a resource too: only true.

  • can you clarify? It turns out that for 10 "it is enough for me to add the layout-sw800 with predefined styles and when the orientation changes, it will be loaded exactly? - St. Ivan
  • layout-sw800-land, when you change the orientation, the folder with this resource will pull up, but you will not prevent the orientation change, for other cases. Therefore, we need a different approach, I did not immediately understand the essence of the issue, only after your last comment, now I will add - Shwarz Andrei