i have activity , b, shared element transition, works fine, until:
- transition -> b in portrait orientation
- in b, change orientation landscape
- hit back
- the shared element doesn't know return, floats there stupidly in place until reenter transition finishes, disappears
this looks awkward. understand because shared element connected portrait landscape of a, , not landscape one. can done alleviate pain?
i checked google play store app exact same scenario described above, selecting app list, going list after orientation change. seems pop list without animation, lot better, there's @ least no broken transition , floating elements. way achieve behavior?
update: make clear, following scenario works perfectly fine:
- transition -> b in portrait orientation
- in b, change orientation landscape
- change orientation again, portrait
- hit back
- the shared element job , returns a
so not case view doesn't survive configuration changes.
i'm answering own question, @ least part regarding how previous activity without transition after orientation change.
- in activity
oncreate()
, create or restore retained fragment holding original screen orientation override
onbackpressed()
, check if current screen orientation same original. if not, finish activity (no transition).private state state; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); initstate(); } private void initstate() { string tag = "state"; fragmentmanager fm = getfragmentmanager(); // find or create fragment this.state = (state) fm.findfragmentbytag(tag); if (this.state == null) { this.state = new state(); fm.begintransaction().add(this.state, tag).commit(); // store original screen orientation this.state.originalorientation = getresources().getconfiguration().orientation; } } @override public void onbackpressed() { // shared element broken if (getresources().getconfiguration().orientation != state.originalorientation) { // no transition finish(); } else { // default behavior super.onbackpressed(); } } public static class state extends fragment { private int originalorientation; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setretaininstance(true); } }
it better fix original problem, no transition still better broken one.
Comments
Post a Comment