How to rotate my application 180 degree upside down upon rotating device 180 degree upside down?

后端 未结 2 1846
滥情空心
滥情空心 2020-12-31 10:56

I have developed one application and configured its orientation is Landscape so it will always display on landscape view on the device.

Now i want to rotate it 180

相关标签:
2条回答
  • 2020-12-31 11:33

    In your AndroidManifest.xml file, you need to configure the <activity> to use the orientation from the sensor. This should be the default, but you can force it to the sensor's orientations, for all 4 possible orientations, with android:screenOrientation="fullSensor". See http://developer.android.com/guide/topics/manifest/activity-element.html#screen

    EDIT: If you want to enable all but one orientation, you could disable that orientation by intercepting the orientation change event and quashing it in your Activity:

    public void onConfigurationChanged(Configuration config) {
      if (config.orientation != Activity.ORIENTATION_PORTRAIT) {
        setRequestedOrientation(config.orientation);
      {
    }
    

    (This is off the top of my head but think it works, or something nearly like it.)

    You need to tell Android to let the app handle orientation changes too in your <activity> with android:configChanges="orientation".

    0 讨论(0)
  • 2020-12-31 11:52

    specify:

    android:screenOrientation="sensorLandscape"
    

    in your AndroidManifest.xml. This will transform application between landscape and reverseLandscape.

    0 讨论(0)
提交回复
热议问题