From b4647929a87e5099662e767e5ca7b43a4b267aea Mon Sep 17 00:00:00 2001 From: tpcstld Date: Sun, 19 Apr 2015 01:35:42 -0700 Subject: [PATCH] Make the game over text automatically resize --- .../src/main/java/com/tpcstld/twozerogame/MainView.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/2048/2048/src/main/java/com/tpcstld/twozerogame/MainView.java b/2048/2048/src/main/java/com/tpcstld/twozerogame/MainView.java index bf45f64..5ce02c1 100644 --- a/2048/2048/src/main/java/com/tpcstld/twozerogame/MainView.java +++ b/2048/2048/src/main/java/com/tpcstld/twozerogame/MainView.java @@ -524,13 +524,19 @@ private void getLayout(int width, int height) { 1000f * (widthWithPadding / (paint.measureText(getResources().getString(R.string.instructions)))), textSize / 1.5f ); + gameOverTextSize = Math.min( + Math.min( + 1000f * ((widthWithPadding - gridWidth * 2) / (paint.measureText(getResources().getString(R.string.game_over)))), + textSize * 2 + ), + 1000f * ((widthWithPadding - gridWidth * 2) / (paint.measureText(getResources().getString(R.string.you_win)))) + ); paint.setTextSize(cellSize); cellTextSize = textSize; titleTextSize = textSize / 3; bodyTextSize = (int) (textSize / 1.5); headerTextSize = textSize * 2; - gameOverTextSize = textSize * 2; textPaddingSize = (int) (textSize / 3); iconPaddingSize = (int) (textSize / 5);