make it look nice
parent
ee26f6b659
commit
372f34ff03
|
@ -8,8 +8,34 @@ import androidx.core.graphics.Insets;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
public class MainCalculatorActivity extends AppCompatActivity {
|
||||
|
||||
public static String formatDecimal(double value) {
|
||||
BigDecimal decimalValue = BigDecimal.valueOf(value);
|
||||
|
||||
String pattern;
|
||||
|
||||
if (decimalValue.stripTrailingZeros().scale() <= 0) {
|
||||
pattern = "#,##0";
|
||||
} else {
|
||||
pattern = "#,##0.##";
|
||||
}
|
||||
|
||||
DecimalFormat df = new DecimalFormat(pattern);
|
||||
|
||||
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
|
||||
symbols.setDecimalSeparator('.');
|
||||
symbols.setGroupingSeparator(',');
|
||||
|
||||
df.setDecimalFormatSymbols(symbols);
|
||||
|
||||
return df.format(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="16dp" />
|
||||
</shape>
|
|
@ -16,6 +16,7 @@
|
|||
android:clickable="false"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:subtitleTextAppearance="@style/TextAppearance.AppCompat.Large">
|
||||
|
||||
<TextView
|
||||
|
@ -30,9 +31,6 @@
|
|||
android:textSize="34sp" />
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
|
||||
<!--I know you can use a grid as shown in class but linear layout feels-->
|
||||
<!--like the more modern solution, plus i just like it more :3-->
|
||||
<!--it also feels more contained which i like-->
|
||||
<LinearLayout
|
||||
android:id="@+id/alignmentLayout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -46,7 +44,7 @@
|
|||
android:id="@+id/calsbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_weight="10"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
|
@ -58,7 +56,7 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/output"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
style="@style/TextAutoScaleStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="10"
|
||||
|
|
|
@ -7,339 +7,233 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".MainCalculatorActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bs"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:text="S"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/br"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b0" />
|
||||
<!--I know you can use a grid as shown in class but linear layout feels-->
|
||||
<!--like the more modern solution, plus i just like it more :3-->
|
||||
<!--it also feels more contained which i like-->
|
||||
<LinearLayout
|
||||
android:id="@+id/alignmentLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bc"
|
||||
android:layout_width="0dp"
|
||||
<LinearLayout
|
||||
android:id="@+id/titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:text="C"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ba"
|
||||
app:layout_constraintStart_toEndOf="@+id/br"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bequals" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ba"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:text="A"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/bc"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bdiv" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/br"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:text="R"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bc"
|
||||
app:layout_constraintStart_toEndOf="@+id/bs"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bdot" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b0"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="0"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bs"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bdot"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bequals"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="="
|
||||
app:layout_constraintBottom_toTopOf="@+id/bc"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bdiv"
|
||||
app:layout_constraintStart_toEndOf="@+id/bdot"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bdiv"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="÷"
|
||||
app:layout_constraintBottom_toTopOf="@+id/ba"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/bequals"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bmul" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bdot"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="."
|
||||
app:layout_constraintBottom_toTopOf="@+id/br"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bequals"
|
||||
app:layout_constraintStart_toEndOf="@+id/b0"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="2"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bdot"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b3"
|
||||
app:layout_constraintStart_toEndOf="@+id/b1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b5" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b0"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b2"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b4" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bmul"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="x"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bdiv"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/b3"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bminus" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="3"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bequals"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bmul"
|
||||
app:layout_constraintStart_toEndOf="@+id/b2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b6" />
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/materialToolbar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:layout_weight="1"
|
||||
android:background="#7986CB"
|
||||
android:clickable="false"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:subtitleTextAppearance="@style/TextAppearance.AppCompat.Large" />
|
||||
android:theme="?attr/actionBarTheme">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
style="@style/TextAutoScaleStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Balculator"
|
||||
android:textColor="#FBFBFB"
|
||||
android:textSize="34sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/materialToolbar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:textColor="#FBFBFB" />
|
||||
</com.google.android.material.appbar.MaterialToolbar>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/calsbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="2"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/materialToolbar" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/output"
|
||||
android:layout_width="0dp"
|
||||
style="@style/TextAutoScaleStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="6dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider" />
|
||||
android:layout_weight="10"
|
||||
android:gravity="end|center_vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/output" />
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/listDivider" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/row1"
|
||||
android:paddingTop="2dp"
|
||||
style="@style/LinearLayoutStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/b7"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="7"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b4"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b8"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider2" />
|
||||
android:id="@+id/bpar"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="#4DB6AC"
|
||||
android:text="( )" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b8"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="8"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b5"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b9"
|
||||
app:layout_constraintStart_toEndOf="@+id/b7"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider2" />
|
||||
android:id="@+id/bac"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/clearButtons"
|
||||
android:text="AC" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b9"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="9"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b6"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bplus"
|
||||
app:layout_constraintStart_toEndOf="@+id/b8"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider2" />
|
||||
android:id="@+id/bc"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/clearButtons"
|
||||
android:text="C" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bplus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="+"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bminus"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/b9"
|
||||
app:layout_constraintTop_toBottomOf="@+id/divider2" />
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/operatorButtons"
|
||||
android:text="+" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/row2"
|
||||
style="@style/LinearLayoutStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/b7"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="7" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b8"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="8" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b9"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="9" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bdiv"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/operatorButtons"
|
||||
android:text="÷" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/row3"
|
||||
style="@style/LinearLayoutStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/b4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="4"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b7" />
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="4" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="5"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/b6"
|
||||
app:layout_constraintStart_toEndOf="@+id/b4"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b8" />
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="5" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b6"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="6"
|
||||
app:layout_constraintBottom_toTopOf="@+id/b3"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bminus"
|
||||
app:layout_constraintStart_toEndOf="@+id/b5"
|
||||
app:layout_constraintTop_toBottomOf="@+id/b9" />
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="6" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bmul"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/operatorButtons"
|
||||
android:text="*" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/row4"
|
||||
style="@style/LinearLayoutStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/b1"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b2"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="2" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b3"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="3" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bminus"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:text="-"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bmul"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/b6"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bplus" />
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/operatorButtons"
|
||||
android:text="-" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/row5"
|
||||
android:paddingBottom="2dp"
|
||||
style="@style/LinearLayoutStyle">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bdot"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/specialButtons"
|
||||
android:text="." />
|
||||
|
||||
<Button
|
||||
android:id="@+id/b0"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/numberButtons"
|
||||
android:text="0" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bneg"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/specialButtons"
|
||||
android:text="+/-" />
|
||||
|
||||
<!-- i put equals last because it puts it close to the thumb-->
|
||||
<Button
|
||||
android:id="@+id/bequals"
|
||||
style="@style/CalculatorButtonTextStyle"
|
||||
android:backgroundTint="@color/equalsButton"
|
||||
android:text="=" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -7,4 +7,9 @@
|
|||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="specialButtons">#4DB6AC</color>
|
||||
<color name="clearButtons">#E57373</color>
|
||||
<color name="operatorButtons">#81C784</color>
|
||||
<color name="numberButtons">#7986CB</color>
|
||||
<color name="equalsButton">#4FC3F7</color>
|
||||
</resources>
|
|
@ -1,9 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="CalculatorButtonTextStyle">
|
||||
<style name="TextAutoScaleStyle">
|
||||
<item name="autoSizeTextType">uniform</item>
|
||||
<item name="autoSizeMinTextSize">10sp</item>
|
||||
<item name="autoSizeMaxTextSize">256sp</item>
|
||||
<item name="autoSizeStepGranularity">2sp</item>
|
||||
</style>
|
||||
|
||||
<style name="CalculatorButtonTextStyle">
|
||||
<item name="autoSizeTextType">uniform</item>
|
||||
<item name="autoSizeMinTextSize">10sp</item>
|
||||
<item name="autoSizeMaxTextSize">256sp</item>
|
||||
<item name="autoSizeStepGranularity">2sp</item>
|
||||
<item name="android:layout_marginStart">4dp</item>
|
||||
<item name="android:layout_marginEnd">4dp</item>
|
||||
<item name="android:maxLines">1</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:gravity">center</item>
|
||||
</style>
|
||||
|
||||
<style name="LinearLayoutStyle">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">0dp</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:background">#2F2F2F</item>
|
||||
<item name="android:orientation">horizontal</item>
|
||||
<item name="android:paddingLeft">2dp</item>
|
||||
<item name="android:paddingRight">2dp</item>
|
||||
</style>
|
||||
</resources>
|
Loading…
Reference in New Issue