1

以编程方式动画开始活动

在高层次上,我的项目是一个库,它显示从集成应用程序传入的另一个活动的活动。

我正在尝试为要显示的活动添加上滑动画。Tbh,我对任何活动动画都很满意。

由于这是一个应用程序将集成的库,因此我不想包含任何动画 XML 文件,并且我也无权访问主清单文件。我需要以编程方式执行此操作。

我努力了:

// Activity from library
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate( savedInstanceState );
    requestWindowFeature( Window.FEATURE_NO_TITLE ); 
    requestWindowFeature( Window.FEATURE_ACTIVITY_TRANSITIONS );

    // Create animation
    Slide slide = new Slide();
    slide.setDuration( 3000 );

    // Set enter and exit transitions
    getWindow().setEnterTransition( slide );
    getWindow().setExitTransition( slide );

    // Finally set content view
    setContentView( createContentView() );
}
4

1 回答 1

0

So far, there doesn't seem to be a way to do this without introducing an external dependency. We're now distributing the library as an AAR, and with it comes various animation XML files which resolves the original question.

于 2019-01-18T03:07:52.553 回答