سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

You don’t have to completely reimplement the draw method. Just implement a custom draw method in your MapView subclass that applies a rotation to the Canvas, calls super.draw(), and then restores the previous Canvas transformation. Simples!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top