adding a nicer circular background to buttons

This commit is contained in:
tibbi 2022-12-21 16:27:53 +01:00
parent c8b4ebbd21
commit 822449cb95
4 changed files with 21 additions and 2 deletions

View File

@ -93,6 +93,11 @@ class MainActivity : SimpleActivity(), Calculator {
val properPrimaryColor = getProperPrimaryColor() val properPrimaryColor = getProperPrimaryColor()
arrayOf(btn_percent, btn_power, btn_root, btn_clear, btn_reset, btn_divide, btn_multiply, btn_plus, btn_minus, btn_equals, btn_decimal).forEach { arrayOf(btn_percent, btn_power, btn_root, btn_clear, btn_reset, btn_divide, btn_multiply, btn_plus, btn_minus, btn_equals, btn_decimal).forEach {
it.setTextColor(properPrimaryColor) it.setTextColor(properPrimaryColor)
it.background?.alpha = 200
}
arrayOf(btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9).forEach {
it.background?.alpha = 80
} }
} }

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorPrimaryDark">
<item android:id="@+id/button_circular_background_holder">
<layer-list>
<item android:id="@+id/button_circular_background_shape">
<shape android:shape="oval">
<solid android:color="@color/divider_grey" />
</shape>
</item>
</layer-list>
</item>
</ripple>

View File

@ -4,7 +4,7 @@
<dimen name="min_widget_width">180dp</dimen> <dimen name="min_widget_width">180dp</dimen>
<dimen name="min_widget_height">180dp</dimen> <dimen name="min_widget_height">180dp</dimen>
<dimen name="button_text_size">28sp</dimen> <dimen name="button_text_size">34sp</dimen>
<dimen name="formula_text_size">20sp</dimen> <dimen name="formula_text_size">20sp</dimen>
<dimen name="display_text_size">40sp</dimen> <dimen name="display_text_size">40sp</dimen>
</resources> </resources>

View File

@ -3,11 +3,12 @@
<style name="AppTheme" parent="AppTheme.Base" /> <style name="AppTheme" parent="AppTheme.Base" />
<style name="MyButton" parent="ShapeAppearanceOverlay.Material3.Button"> <style name="MyButton" parent="ShapeAppearanceOverlay.Material3.Button">
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item> <item name="android:background">@drawable/button_circular_background</item>
<item name="android:textSize">@dimen/button_text_size</item> <item name="android:textSize">@dimen/button_text_size</item>
<item name="android:fontFamily">sans-serif-light</item> <item name="android:fontFamily">sans-serif-light</item>
<item name="android:textAllCaps">false</item> <item name="android:textAllCaps">false</item>
<item name="android:padding">0dp</item> <item name="android:padding">0dp</item>
<item name="android:layout_margin">@dimen/medium_margin</item>
</style> </style>
</resources> </resources>