Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a good way using <a href="http://developer.android.com/guide/topics/resources/more-resources.html#Bool" rel="noreferrer">resources</a> and <a href="http://developer.android.com/guide/practices/screens_support.html#NewQualifiers" rel="noreferrer">size qualifiers</a>.</p> <p>Put this bool resource in res/values as bools.xml or whatever (file names don't matter here):</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;bool name="portrait_only"&gt;true&lt;/bool&gt; &lt;/resources&gt; </code></pre> <p>Put this one in res/values-sw600dp and res/values-xlarge:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;bool name="portrait_only"&gt;false&lt;/bool&gt; &lt;/resources&gt; </code></pre> <p>See <a href="https://stackoverflow.com/a/39302787">this supplemental answer</a> for help adding these directories and files in Android Studio.</p> <p>Then, in the onCreate method of your Activities you can do this:</p> <pre><code> if(getResources().getBoolean(R.bool.portrait_only)){ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } </code></pre> <p>Devices that are more than 600 dp in the smallest width direction, or x-large on pre-Android 3.2 devices (tablets, basically) will behave like normal, <a href="http://developer.android.com/reference/android/R.attr.html#screenOrientation" rel="noreferrer">based on sensor and user-locked rotation, etc</a>. Everything else (phones, pretty much) will be portrait only.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload