Created
November 30, 2020 13:46
-
-
Save maiconhellmann/89d346e898a85ee2458a8aad03eabc4c to your computer and use it in GitHub Desktop.
screenOrientation - smartphone = PORTRAIT and tablet = DYNAMIC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<bool name="portrait_only">true</bool> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activi | |
android:name=".MyAmazingActivity" | |
android:configChanges="orientation|screenSize" | |
android:screenOrientation="behind"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyAmazingActivity: AppCompatActivity { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
if (resources.getBoolean(R.bool.portrait_only)) { | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) | |
} else { | |
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<bool name="portrait_only">false</bool> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment