2017-01-27 7 views
1

なぜ180度の画面の急な回転は構成の変更として数えられないので、それはActivity.onCreate()をトリガーしていません!だから私はカメラの見方を再調整できません! 90度回転すると、毎回設定が変更されます。 私のマニフェストにはconfigChangesのいずれもorientationという属性がないので、ソースコードを省略します。アクティビティには何も特別なものはありません。これは意図された動作だと思われますが、正式な情報はありません。なぜ画面の180度の回転が設定変更としてカウントされないのですか?

デバイス:ハードウェアネクサス5X

プラットフォーム:アンドロイド7.1.1

マニフェスト:

<supports-screens 
    android:anyDensity="true" 
    android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="false" 
    android:xlargeScreens="true" /> 

<application 
    android:name="xyz.MyApp" 
    android:allowBackup="true" 
    android:backupAgent=".provider.MyBackupAgent" 
    android:hardwareAccelerated="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:restoreAnyVersion="true" 
    android:theme="@style/AppTheme" 
    android:uiOptions="splitActionBarWhenNarrow" 
    tools:replace="android:icon" > 

<activity android:name="xyz.MyActivity" 
     android:label="asdf" 
     android:theme="@style/Theme" /> 

のstyles.xml:

<style name="Theme" parent="Theme.AppCompat.NoActionBar"> 
    <item name="actionBarIconColor">#fff</item> 
    <item name="actionBarInsetStart">@dimen/keyline_2</item> 
</style> 

スタイル-V19 .xm L:

<style name="Theme" parent="Theme.AppCompat.NoActionBar"> 
    <item name="actionBarIconColor">#fff</item> 
    <item name="actionBarInsetStart">@dimen/keyline_2</item> 
    <item name="android:windowTranslucentStatus">true</item> 
    <item name="android:windowTranslucentNavigation">true</item> 
</style> 
+0

を使用することができ17+ある場合

final WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); OrientationEventListener orientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) { @Override public void onOrientationChanged(int orientation) { if (orientation == ORIENTATION_UNKNOWN) { return; } Display display = mWindowManager.getDefaultDisplay(); int rotation = display.getRotation(); if (rotation != mLastRotation) { // do something with your views mLastRotation = rotation; } } }; if (orientationEventListener.canDetectOrientation()) { orientationEventListener.enable(); } 

をそれを肖像(または風景)にしておくので、何も必要ありません。 –

+0

さて、それはカメラのプレビューを上下逆さまにする! – WindRider

答えて

2

説明hereデフォルトの方向が逆縦向きを無視したsensorであるとして、あなたはAndroidManifest.xml であなたの活動のためのandroid:screenOrientation="fullSensor"を指定する必要があります。 fullSensorは4方向すべてを許可します

更新日:上記の回答では問題は解決しません。中核的な問題は、方位を180度変えること(すなわち、風景から逆景観へ)が活動の再創造を引き起こさないことである。これは予想される動作です。一般的には、ランドスケープのレイアウトは、逆のランドスケープのレイアウトと変わりません。 あなたは180で回転させた後、あなたの意見の一部を変更したい場合は、OrientationEventListener

サンプルを使用することができます:あなたのminSdkが180度回転するので、あなたもDisplayListener#onDisplayChangedコールバック

+0

それは完全に理にかなっていますが、それでも動作しません。 – WindRider

+0

@WindRiderアクティビティとAndroidManifest.xmlのコードで質問を更新できますか? – nnesterov

+0

私はあなたがどんな活動でもそれを再現できると確信しています。私は他の活動や他のアプリでそれをやった。これは、プラットフォームが期待する動作のようです。 – WindRider

関連する問題