Skip to content

Activity configuration

Marc Auberer edited this page Dec 20, 2020 · 2 revisions

Activity configuration

Custom activity transitions

Maybe you want to change the default activity transition animations to some custom animation set, you provide by yourself. To do so, you might want to apply those animations to both, the opening and closing transitions of the SimpleSettingsActivity. To set the transition animations for the activity start, you can simply add the overridePendingTransition method call, after calling the show method of the SimpleSettings object. Here an example:

SimpleSettings(this).show(R.xml.preferences)
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right)

This works for both, code configuration and XML configuration.

To now set also the activity transition while closing the activity, you need to extend the example code as follows:

val config = SimpleSettingsConfig.Builder()
   .setPendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right)
   .build()

SimpleSettings(this, config).show(R.xml.preferences)
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right)

The activity will apply the transition, you attach via the setPendingTransition method of the SimpleSettingsConfigBuilder.