Bordeless Style added and Still not figured out how to set Text Size correct

This commit is contained in:
Gongxter 2015-11-17 14:53:20 +01:00
parent d3abad12a2
commit 4bfdf01a9a
4 changed files with 34 additions and 19 deletions

View file

@ -17,7 +17,7 @@ public class SudokuButton extends Button {
private SudokuButtonType type = SudokuButtonType.Unspecified; private SudokuButtonType type = SudokuButtonType.Unspecified;
public SudokuButton(Context context, AttributeSet attrs) { public SudokuButton(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs,R.attr.borderlessButtonStyle);
} }
public void setValue(int value) { this.value = value; } public void setValue(int value) { this.value = value; }

View file

@ -2,6 +2,7 @@ package tu_darmstadt.sudoku.ui.view;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
@ -85,14 +86,21 @@ public class SudokuKeyboardLayout extends GridLayout {
public void setNotesEnabled(boolean b) { public void setNotesEnabled(boolean b) {
notesEnabled = b; notesEnabled = b;
} if(notesEnabled) {
setTextSize(buttons[0].getPaint().getTextSize()/2);
public void setValueSize (float size){ }else {
for (int i = 0; i< buttons.length;i++){ setTextSize(buttons[0].getPaint().getTextSize()*2);
buttons[i].setTextSize(size);
} }
} }
private void setTextSize(float size){
for (SudokuButton b : buttons){
//b.setTextSize(size);
b.getPaint().setTextSize(size);
}
}
@Override @Override
public void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {

View file

@ -22,7 +22,6 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
SudokuButton [] fixedButtons; SudokuButton [] fixedButtons;
public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size(); public int fixedButtonsCount = SudokuButtonType.getSpecialButtons().size();
String [] s = {"Do","Un","off","Del","Sh**","Hi"};
GameController gameController; GameController gameController;
boolean notesEnabled=false; boolean notesEnabled=false;
SudokuKeyboardLayout keyboard; SudokuKeyboardLayout keyboard;
@ -42,7 +41,6 @@ public class SudokuSpecialButtonLayout extends LinearLayout {
notesEnabled = !notesEnabled; notesEnabled = !notesEnabled;
btn.setText(notesEnabled ? "ON" : "OFF"); btn.setText(notesEnabled ? "ON" : "OFF");
keyboard.setNotesEnabled(notesEnabled); keyboard.setNotesEnabled(notesEnabled);
keyboard.setValueSize(notesEnabled ?btn.getTextSize()/4: btn.getTextSize()/2 );
break; break;
case Do: case Do:
// TODO: not implemented // TODO: not implemented

View file

@ -13,7 +13,6 @@
android:id="@+id/appbar" android:id="@+id/appbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay"> android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
@ -32,7 +31,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="10" android:weightSum="10"
android:layout_marginTop="?attr/actionBarSize"> android:layout_marginTop="?attr/actionBarSize"
style="?android:buttonBarStyle">
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
android:id="@+id/scroller" android:id="@+id/scroller"
@ -58,7 +58,8 @@
android:weightSum="8" android:weightSum="8"
android:divider="#000" android:divider="#000"
android:baselineAligned="false" android:baselineAligned="false"
android:gravity="center_horizontal"> android:gravity="center_horizontal"
style="?android:buttonBarStyle">
<RatingBar <RatingBar
@ -84,7 +85,8 @@
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" android:clickable="false"
android:elevation="10dp"/> android:elevation="10dp"
style="?android:attr/borderlessButtonStyle"/>
<Button <Button
android:layout_width="match_parent" android:layout_width="match_parent"
@ -98,13 +100,15 @@
android:layout_weight="2" android:layout_weight="2"
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" /> android:clickable="false"
style="?android:attr/borderlessButtonStyle"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="2" android:layout_weight="2"
android:weightSum="2"> android:weightSum="2"
style="?android:buttonBarStyle">
<Button <Button
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -117,7 +121,8 @@
android:layout_weight="1" android:layout_weight="1"
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" /> android:clickable="false"
style="?android:attr/borderlessButtonStyle"/>
<Button <Button
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -130,13 +135,15 @@
android:layout_weight="1" android:layout_weight="1"
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" /> android:clickable="false"
style="?android:attr/borderlessButtonStyle"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="2" android:layout_weight="2"
android:weightSum="2"> android:weightSum="2"
style="?android:buttonBarStyle">
<Button <Button
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -149,7 +156,8 @@
android:layout_weight="1" android:layout_weight="1"
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" /> android:clickable="false"
style="?android:attr/borderlessButtonStyle"/>
<Button <Button
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -162,7 +170,8 @@
android:layout_weight="1" android:layout_weight="1"
android:onClick="onClick" android:onClick="onClick"
android:capitalize="none" android:capitalize="none"
android:clickable="false" /> android:clickable="false"
style="?android:attr/borderlessButtonStyle"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>