2012-11-08 30 views
3

我試着爲橫向和縱向設置兩個啓動畫面。對於這一點,我在活動課中寫道下面的代碼改變Android中的方向時,SplashScreen沒有改變PhoneGap

if (getResources().getConfiguration().orientation == 2) { 
      super.setIntegerProperty("splashscreen", R.drawable.equipsplashscreen); 
      Log.d("Orientation", "Landscape"); 
     } 
     else { 
      super.setIntegerProperty("splashscreen", R.drawable.splashscreen); 
      Log.d("Orientation", "Portrait"); 
     } 

屏幕根據方向顯示,但問題是..在加載屏幕沒有變化(即我開始了我在縱向模式下的應用程序,同時加載啓動畫面我將方向從縱向更改爲橫向,那時我的橫向圖像未加載..只有縱向圖像更改爲橫向樣式)。

我使用的科爾多瓦 - 1.8.0和jQuery-1.7.1

我怎樣才能做到這一點..在此先感謝..

回答

0

在Android中我們已經覆蓋這樣

的onConfigurationChanged方法
@Override 
public void onConfigurationChanged(Configuration newConfig) { 

    super.onConfigurationChanged(newConfig); 
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { 
     setContentView(R.layout.splashscreen); 
     init(); 
    } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { 
     setContentView(R.layout.splashscreen); 
     init(); 
    } 
} 

而且在清單中添加一個標籤這樣

<activity 
    android:name=".YourActivity" 
    android:configChanges="orientation|keyboardHidden" 
    android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan" /> 

現在CHEC k phonegap中的要求,因爲我不知道電話差距我給你提示在android中做了什麼。