java - Lock screen orientation within View class - Android -
i know how within activity class, doesn't fit need. within class extends view, once method called screen orientation locked. , once method called unlocked.
is there way can within class extends view?
thanks.
@override public void onconfigurationchanged(configuration newconfig) { // todo auto-generated method stub super.onconfigurationchanged(newconfig); setcontentview(this.gameview); if (this.gameview.isorientationchange() == false) { // stop screen orientation changing during event switch (this.getresources().getconfiguration().orientation) { case configuration.orientation_portrait: this.setrequestedorientation(activityinfo.screen_orientation_landscape); break; case configuration.orientation_landscape: this.setrequestedorientation(activityinfo.screen_orientation_portrait); break; } } else { // allow screen rotations this.setrequestedorientation(activityinfo.screen_orientation_unspecified); } }
in class extending view, there orientationchange boolean field. changed method indicating whether devices orientation can changed. worked screen size changes when orientation changed. if there lot of code dependent on size , timed, may cause more problems solve.
Comments
Post a Comment