Forum Xamarin.Forms

How can I rotate only a specific part of screen?

As a question title, I wonder how to rotate only a specific part of screen
For example, most of camera application lock the rotation of screen and only button rotate when device tilts.
How can I implement this? I've already looked xam.plugin.Devicemotion but I don't know how to use it and no example I can find :(
Please help me..Thank you

Tagged:

Answers

  • JohnHardmanJohnHardman GBUniversity admin
    edited February 2018

    @CoffeeSupreme - See https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/rotation/

    Depending on what you want to do, it may be as simple as setting the Rotation property on a View.

  • CoffeeSupremeCoffeeSupreme Member ✭✭
    edited March 2018

    @JohnHardman Oops, I'm very sorry. I forgot to mention rotate only under specific condition such that if device sense orientation

  • JohnHardmanJohnHardman GBUniversity admin
    edited March 2018

    @CoffeeSupreme - You'd still use the Rotation property on the View. You just need to change the property when your trigger action happens. Detecting when the orientation of a physical device changes has been discussed in other forum threads, so you should find how to do that with a quick Google. If I have understood what you are trying to do correctly, this will not be a case of comparing the page's Width and Height, but a case of getting the physical orientation. I haven't used it, but you might want to look at https://github.com/wcoder/Xamarin.Plugin.DeviceOrientation to see if that provides what you need in terms of orientation change detection.

  • CoffeeSupremeCoffeeSupreme Member ✭✭

    @JohnHardman Thanks to your very appreciate help, I solve the problem. I didn't use that plugin but through that, I get the clue for my problem. Thanks again :)

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    So what was your solution?
  • CoffeeSupremeCoffeeSupreme Member ✭✭

    @JamesLavery I just used Xam.Plugin.DeviceMotion. It provides device motion sensor and by this, I could get a vector value. Also, specific motion such as rotate to landscape, portrait has specific value in specific range. I used that value.

  • CoffeeSupremeCoffeeSupreme Member ✭✭

    @JamesLavery But, the documents or sample is hard to find. If you need any help for usage. Just let me know.

Sign In or Register to comment.