Reimplement toogleLayout feature

Change-Id: I43139216217fc791b71878fb34a1a45e66fd3955