From 123c745fa50074924266f16e6c6e69b0fbe1acce Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 16 Feb 2015 09:25:26 +0100 Subject: [PATCH] cpp-127: Text size in the buttons on tablet (Big buttons) For some reason getDimension now returns dimension in pixels (?). Calling getDimensionPixelSize fixes the problem. Also optimized font size for large xhdpi tablets Fixes #127 --- .../android/calculator/CalculatorButtons.java | 4 +-- .../main/res/values-large-xhdpi/dimens.xml | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 android-app/src/main/res/values-large-xhdpi/dimens.xml diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 08fdb7b0..2b10327e 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -64,12 +64,12 @@ public final class CalculatorButtons { @Nonnull View root) { if (!layout.isOptimized()) { - final float textSize = root.getContext().getResources().getDimension(R.dimen.cpp_keyboard_button_text_size_mobile); + final float textSize = root.getContext().getResources().getDimensionPixelSize(R.dimen.cpp_keyboard_button_text_size_mobile); Views.processViewsOfType(root, DragButton.class, new Views.ViewProcessor() { @Override public void process(@Nonnull DragButton button) { - button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize); + button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); } }); } diff --git a/android-app/src/main/res/values-large-xhdpi/dimens.xml b/android-app/src/main/res/values-large-xhdpi/dimens.xml new file mode 100644 index 00000000..75ce2f3b --- /dev/null +++ b/android-app/src/main/res/values-large-xhdpi/dimens.xml @@ -0,0 +1,26 @@ + + + + 30dp + 40dp + \ No newline at end of file