[英]Android Layout issue of Portrait and Landscape
朋友您好,我是Android開發和Stackoverflow的新手,我在android布局中遇到一些問題,我創建了兩個布局文件夾,一個用於縱向,一個用於橫向(均為平板電視TVDPI)
layout-sw600dp-land-tvdpi和layout-sw600dp-port-tvdpi
我面臨的問題是,當我以縱向模式運行程序時,它可以顯示正確的縱向布局,但是當我將設備縱向變為橫向時,則可以顯示相同的縱向布局,而在橫向模式下運行時可以顯示相同的情況正確運行並轉向potrait它向我展示了景觀布局...
為什么?
嘗試這個
#region Handle State on Orientation
//this has been done using better technique
protected override void OnSaveInstanceState(Bundle outState)
{
base.OnSaveInstanceState(outState);
//adding spinner/dropdownlist selected item
if (ViewModel.IsLoading == true)
{
isLoadingState = true;
AndroidHUD.AndHUD.Shared.Dismiss(this);
}
var preferences = GetSharedPreferences("TmsAppData", FileCreationMode.Private);
var editor = preferences.Edit();
//editor.PutString("DeviceId", registrationId);
editor.PutBoolean("IsOrientationChange", true);
editor.Commit();
//outState.PutInt("_AlreadySelectedPostion", _AlreadySelectedPostion);
outState.PutBoolean("_isLoadingState", isLoadingState);
}
protected override void OnRestoreInstanceState(Bundle savedInstanceState)
{
base.OnRestoreInstanceState(savedInstanceState);
//setting a flag to manage spinner selected state
_IsStateViewActive = true;
isLoadingState = savedInstanceState.GetBoolean("_isLoadingState");
if (ViewModel.IsLoading == true)
{
isLoadingState = false;
ViewModel.IsLoading = true;
}
//getting the previous selected item from the saved state for spinner / dropdownlist
//_AlreadySelectedPostion = savedInstanceState.GetInt("_AlreadySelectedPostion");
}
#endregion
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.