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
This commit is contained in:
serso 2015-02-16 09:25:26 +01:00
parent 31e31b9cbe
commit 123c745fa5
2 changed files with 28 additions and 2 deletions

View File

@ -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<DragButton>() {
@Override
public void process(@Nonnull DragButton button) {
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
}
});
}

View File

@ -0,0 +1,26 @@
<!--
~ Copyright 2013 serso aka se.solovyev
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Contact details
~
~ Email: se.solovyev@gmail.com
~ Site: http://se.solovyev.org
-->
<resources>
<dimen name="cpp_keyboard_button_text_size">30dp</dimen>
<dimen name="cpp_keyboard_button_text_size_mobile">40dp</dimen>
</resources>