Search code examples
androidbitmapscreenshotlandscapeportrait

Method to programmatically switch between Landscape<->Portrait for a single View on Android?


Is it possible to programmatically (not XML) change a single view (MapView) on Android into landscape mode when running in portrait mode?

I have a Google Map View in my app. Typically the user will run the app in portrait mode but there is a function which will take a bitmap screenshot of the map in its current state but I'd like that to be landscaped without the user having to physically move their phone. Afterwards I'd return the view to its original portrait.


Solution

  • No: orientation is currently handled at the Activity level, not the View level. If you had a completely custom View you could CHOOSE to draw it in landscape yourself (landscape simply being longer side as the horizontal, shorter as the vertical) but with the MapView you don't get that option.