Book Image

Xamarin Mobile Application Development for Android

Book Image

Xamarin Mobile Application Development for Android

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Dynamically requesting the orientation


You can also change the desired activity orientation dynamically by setting the RequestedOrientation property to your activity. This allows further flexibility to dynamically change the orientation anytime as required. Add the following code snippet anywhere in your activity to restrict the currently running activity orientation to landscape only:

RequestedOrientation = ScreenOrientation.Landscape;

The changes made to the RequestedOrientation property has an impact on the activity in the foreground and a request for the specified orientation is made immediately by causing the current activity to restart. You can use the same property to obtain the current configuration that is in effect for the current activity.