Created
October 11, 2014 14:02
-
-
Save avianey/497f9c69d198ea7dd59b to your computer and use it in GitHub Desktop.
Libgdx square AndroidFragmentApplication that fills as much of the screen as possible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); | |
config.useAccelerometer = false; | |
config.useCompass = false; | |
config.useWakelock = true; | |
config.numSamples = 1; | |
config.resolutionStrategy = new ResolutionStrategy() { | |
@Override | |
public MeasuredDimension calcMeasures(int widthMeasureSpec, int heightMeasureSpec) { | |
int width = widthMeasureSpec; | |
int height = heightMeasureSpec; | |
if ((View.MeasureSpec.AT_MOST & widthMeasureSpec) != 0) { | |
width -= View.MeasureSpec.AT_MOST; | |
} else if ((View.MeasureSpec.EXACTLY & widthMeasureSpec) != 0) { | |
width -= View.MeasureSpec.EXACTLY; | |
} | |
if ((View.MeasureSpec.AT_MOST & heightMeasureSpec) != 0) { | |
height -= View.MeasureSpec.AT_MOST; | |
} else if ((View.MeasureSpec.EXACTLY & heightMeasureSpec) != 0) { | |
height -= View.MeasureSpec.EXACTLY; | |
} | |
final int d = Math.min(width, height); | |
return new MeasuredDimension(d, d); | |
} | |
}; | |
return initializeForView(new ReversiGame(), config); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment