【问题标题】:OverridePendingTransition doesn't work if Orientation will change in LandScape programmatically如果方向将以编程方式在 LandScape 中更改,则 OverridePendingTransition 不起作用
【发布时间】:2019-11-21 17:52:34
【问题描述】:

我正在使用两个活动,在第一个活动中,我使用下面的代码来启动第二个活动

 Intent i = new Intent(getBaseContext(), ViewPerson.class);                      
  startActivity(i);
 overridePendingTransition(Resource.Layout.trans_right_in, Resource.Layout.trans_right_out);
 Finish();

然后在第二个活动 onCreate 方法中,我使用下面的代码来更改活动方向

public void onCreate(Bundle savedInstanceState)
{
    if(Parameters.Landscape) //Parameters is a static class
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.filters);
 }

问题是在这种情况下我的动画不起作用。它仅适用于肖像模式。

【问题讨论】:

  • ,你说要改变Activity方向LandScape,它只能在竖屏模式下工作,在改变之前,Activity方向是什么?
  • 可能未指定。我没有在清单中设置方向

标签: java xamarin orientation


【解决方案1】:

我使用以下代码更改了方向,我没有问题。

private void Btn2_Click(object sender, System.EventArgs e)
    {
        RequestedOrientation = ScreenOrientation.Landscape;
    }

    private void Btn1_Click(object sender, System.EventArgs e)
    {
        RequestedOrientation = ScreenOrientation.Portrait;

    }

【讨论】:

    猜你喜欢
    • 2012-05-27
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多