Skip to content

Commit b464792

Browse files
committed
Make the game over text automatically resize
1 parent fe05cbe commit b464792

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

2048/2048/src/main/java/com/tpcstld/twozerogame/MainView.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,19 @@ private void getLayout(int width, int height) {
524524
1000f * (widthWithPadding / (paint.measureText(getResources().getString(R.string.instructions)))),
525525
textSize / 1.5f
526526
);
527+
gameOverTextSize = Math.min(
528+
Math.min(
529+
1000f * ((widthWithPadding - gridWidth * 2) / (paint.measureText(getResources().getString(R.string.game_over)))),
530+
textSize * 2
531+
),
532+
1000f * ((widthWithPadding - gridWidth * 2) / (paint.measureText(getResources().getString(R.string.you_win))))
533+
);
527534

528535
paint.setTextSize(cellSize);
529536
cellTextSize = textSize;
530537
titleTextSize = textSize / 3;
531538
bodyTextSize = (int) (textSize / 1.5);
532539
headerTextSize = textSize * 2;
533-
gameOverTextSize = textSize * 2;
534540
textPaddingSize = (int) (textSize / 3);
535541
iconPaddingSize = (int) (textSize / 5);
536542

0 commit comments

Comments
 (0)