From 4bfdf01a9a1313b8545304a0a5ec242ec984a8d0 Mon Sep 17 00:00:00 2001 From: Gongxter Date: Tue, 17 Nov 2015 14:53:20 +0100 Subject: [PATCH] Bordeless Style added and Still not figured out how to set Text Size correct --- .../sudoku/ui/view/SudokuButton.java | 2 +- .../sudoku/ui/view/SudokuKeyboardLayout.java | 18 ++++++++--- .../ui/view/SudokuSpecialButtonLayout.java | 2 -- .../main/res/layout/activity_main_menu.xml | 31 ++++++++++++------- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java index 9cb8c9e..1d8104e 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuButton.java @@ -17,7 +17,7 @@ public class SudokuButton extends Button { private SudokuButtonType type = SudokuButtonType.Unspecified; public SudokuButton(Context context, AttributeSet attrs) { - super(context, attrs); + super(context, attrs,R.attr.borderlessButtonStyle); } public void setValue(int value) { this.value = value; } diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java index f09a254..d3c9b51 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuKeyboardLayout.java @@ -2,6 +2,7 @@ package tu_darmstadt.sudoku.ui.view; import android.content.Context; import android.graphics.Canvas; +import android.graphics.Paint; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; @@ -85,14 +86,21 @@ public class SudokuKeyboardLayout extends GridLayout { public void setNotesEnabled(boolean b) { notesEnabled = b; - } - - public void setValueSize (float size){ - for (int i = 0; i< buttons.length;i++){ - buttons[i].setTextSize(size); + if(notesEnabled) { + setTextSize(buttons[0].getPaint().getTextSize()/2); + }else { + setTextSize(buttons[0].getPaint().getTextSize()*2); } } + private void setTextSize(float size){ + for (SudokuButton b : buttons){ + //b.setTextSize(size); + b.getPaint().setTextSize(size); + } + } + + @Override public void onDraw(Canvas canvas) { diff --git a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java index 3165608..7e77ad5 100644 --- a/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java +++ b/app/src/main/java/tu_darmstadt/sudoku/ui/view/SudokuSpecialButtonLayout.java @@ -22,7 +22,6 @@ public class SudokuSpecialButtonLayout extends LinearLayout { SudokuButton [] fixedButtons; public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size(); - String [] s = {"Do","Un","off","Del","Sh**","Hi"}; GameController gameController; boolean notesEnabled=false; SudokuKeyboardLayout keyboard; @@ -42,7 +41,6 @@ public class SudokuSpecialButtonLayout extends LinearLayout { notesEnabled = !notesEnabled; btn.setText(notesEnabled ? "ON" : "OFF"); keyboard.setNotesEnabled(notesEnabled); - keyboard.setValueSize(notesEnabled ?btn.getTextSize()/4: btn.getTextSize()/2 ); break; case Do: // TODO: not implemented diff --git a/app/src/main/res/layout/activity_main_menu.xml b/app/src/main/res/layout/activity_main_menu.xml index de70967..317ad3c 100644 --- a/app/src/main/res/layout/activity_main_menu.xml +++ b/app/src/main/res/layout/activity_main_menu.xml @@ -13,7 +13,6 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/appbar_padding_top" android:theme="@style/AppTheme.AppBarOverlay"> + android:layout_marginTop="?attr/actionBarSize" + style="?android:buttonBarStyle"> + android:gravity="center_horizontal" + style="?android:buttonBarStyle"> + android:elevation="10dp" + style="?android:attr/borderlessButtonStyle"/>