properly center texts in buttons

This commit is contained in:
tibbi 2022-12-21 21:16:05 +01:00
parent 8f7895e219
commit 489c4f93bb
7 changed files with 50 additions and 51 deletions

View File

@ -91,16 +91,14 @@ class MainActivity : SimpleActivity(), Calculator {
vibrateOnButtonPress = config.vibrateOnButtonPress
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 {
it.setTextColor(properPrimaryColor)
it.background = ResourcesCompat.getDrawable(resources, R.drawable.button_circular_background, theme)
it.background?.alpha = 200
it.background?.alpha = 90
}
arrayOf(btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9).forEach {
it.background = ResourcesCompat.getDrawable(resources, R.drawable.button_circular_background, theme)
it.background?.alpha = 80
it.background?.alpha = 20
}
}

View File

@ -6,9 +6,9 @@ import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.widget.Button
import android.widget.RemoteViews
import android.widget.SeekBar
import android.widget.TextView
import com.simplemobiletools.calculator.R
import com.simplemobiletools.calculator.extensions.config
import com.simplemobiletools.calculator.helpers.MyWidgetProvider
@ -140,8 +140,8 @@ class WidgetConfigureActivity : SimpleActivity() {
config_save.setTextColor(getProperPrimaryColor().getContrastColor())
viewIds.forEach {
(findViewById<Button>(it)).setTextColor(mTextColor)
(findViewById<Button>(it)).background = null
(findViewById<TextView>(it)).setTextColor(mTextColor)
(findViewById<TextView>(it)).background = null
}
}

View File

@ -5,7 +5,7 @@
<layer-list>
<item android:id="@+id/button_circular_background_shape">
<shape android:shape="oval">
<solid android:color="@color/divider_grey" />
<solid android:color="?attr/colorPrimary" />
</shape>
</item>
</layer-list>

View File

@ -56,7 +56,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_7"
style="@style/MyButton"
android:layout_width="match_parent"
@ -64,7 +64,7 @@
android:layout_weight="1"
android:text="7" />
<Button
<TextView
android:id="@+id/btn_8"
style="@style/MyButton"
android:layout_width="match_parent"
@ -72,7 +72,7 @@
android:layout_weight="1"
android:text="8" />
<Button
<TextView
android:id="@+id/btn_9"
style="@style/MyButton"
android:layout_width="match_parent"
@ -80,7 +80,7 @@
android:layout_weight="1"
android:text="9" />
<Button
<TextView
android:id="@+id/btn_divide"
style="@style/MyButton"
android:layout_width="match_parent"
@ -88,7 +88,7 @@
android:layout_weight="1"
android:text="÷" />
<Button
<TextView
android:id="@+id/btn_clear"
style="@style/MyButton"
android:layout_width="match_parent"
@ -96,7 +96,7 @@
android:layout_weight="1"
android:text="C" />
<Button
<TextView
android:id="@+id/btn_reset"
style="@style/MyButton"
android:layout_width="match_parent"
@ -113,7 +113,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_4"
style="@style/MyButton"
android:layout_width="match_parent"
@ -121,7 +121,7 @@
android:layout_weight="1"
android:text="4" />
<Button
<TextView
android:id="@+id/btn_5"
style="@style/MyButton"
android:layout_width="match_parent"
@ -129,7 +129,7 @@
android:layout_weight="1"
android:text="5" />
<Button
<TextView
android:id="@+id/btn_6"
style="@style/MyButton"
android:layout_width="match_parent"
@ -137,7 +137,7 @@
android:layout_weight="1"
android:text="6" />
<Button
<TextView
android:id="@+id/btn_multiply"
style="@style/MyButton"
android:layout_width="match_parent"
@ -145,7 +145,7 @@
android:layout_weight="1"
android:text="×" />
<Button
<TextView
android:id="@+id/btn_root"
style="@style/MyButton"
android:layout_width="match_parent"
@ -161,7 +161,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_1"
style="@style/MyButton"
android:layout_width="match_parent"
@ -169,7 +169,7 @@
android:layout_weight="1"
android:text="1" />
<Button
<TextView
android:id="@+id/btn_2"
style="@style/MyButton"
android:layout_width="match_parent"
@ -177,7 +177,7 @@
android:layout_weight="1"
android:text="2" />
<Button
<TextView
android:id="@+id/btn_3"
style="@style/MyButton"
android:layout_width="match_parent"
@ -185,7 +185,7 @@
android:layout_weight="1"
android:text="3" />
<Button
<TextView
android:id="@+id/btn_minus"
style="@style/MyButton"
android:layout_width="match_parent"
@ -193,7 +193,7 @@
android:layout_weight="1"
android:text="-" />
<Button
<TextView
android:id="@+id/btn_power"
style="@style/MyButton"
android:layout_width="match_parent"
@ -209,7 +209,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_0"
style="@style/MyButton"
android:layout_width="match_parent"
@ -217,7 +217,7 @@
android:layout_weight="1"
android:text="0" />
<Button
<TextView
android:id="@+id/btn_decimal"
style="@style/MyButton"
android:layout_width="match_parent"
@ -225,7 +225,7 @@
android:layout_weight="1"
android:text="." />
<Button
<TextView
android:id="@+id/btn_equals"
style="@style/MyButton"
android:layout_width="match_parent"
@ -233,7 +233,7 @@
android:layout_weight="1"
android:text="=" />
<Button
<TextView
android:id="@+id/btn_plus"
style="@style/MyButton"
android:layout_width="match_parent"
@ -241,7 +241,7 @@
android:layout_weight="1"
android:text="+" />
<Button
<TextView
android:id="@+id/btn_percent"
style="@style/MyButton"
android:layout_width="match_parent"

View File

@ -40,7 +40,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_percent"
style="@style/MyButton"
android:layout_width="match_parent"
@ -48,7 +48,7 @@
android:layout_weight="1"
android:text="%" />
<Button
<TextView
android:id="@+id/btn_power"
style="@style/MyButton"
android:layout_width="match_parent"
@ -56,7 +56,7 @@
android:layout_weight="1"
android:text="^" />
<Button
<TextView
android:id="@+id/btn_root"
style="@style/MyButton"
android:layout_width="match_parent"
@ -64,7 +64,7 @@
android:layout_weight="1"
android:text="√" />
<Button
<TextView
android:id="@+id/btn_reset"
style="@style/MyButton"
android:layout_width="match_parent"
@ -73,7 +73,7 @@
android:text="AC"
android:visibility="gone" />
<Button
<TextView
android:id="@+id/btn_divide"
style="@style/MyButton"
android:layout_width="match_parent"
@ -89,7 +89,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_7"
style="@style/MyButton"
android:layout_width="match_parent"
@ -97,7 +97,7 @@
android:layout_weight="1"
android:text="7" />
<Button
<TextView
android:id="@+id/btn_8"
style="@style/MyButton"
android:layout_width="match_parent"
@ -105,7 +105,7 @@
android:layout_weight="1"
android:text="8" />
<Button
<TextView
android:id="@+id/btn_9"
style="@style/MyButton"
android:layout_width="match_parent"
@ -113,7 +113,7 @@
android:layout_weight="1"
android:text="9" />
<Button
<TextView
android:id="@+id/btn_multiply"
style="@style/MyButton"
android:layout_width="match_parent"
@ -129,7 +129,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_4"
style="@style/MyButton"
android:layout_width="match_parent"
@ -137,7 +137,7 @@
android:layout_weight="1"
android:text="4" />
<Button
<TextView
android:id="@+id/btn_5"
style="@style/MyButton"
android:layout_width="match_parent"
@ -145,7 +145,7 @@
android:layout_weight="1"
android:text="5" />
<Button
<TextView
android:id="@+id/btn_6"
style="@style/MyButton"
android:layout_width="match_parent"
@ -153,7 +153,7 @@
android:layout_weight="1"
android:text="6" />
<Button
<TextView
android:id="@+id/btn_minus"
style="@style/MyButton"
android:layout_width="match_parent"
@ -169,7 +169,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_1"
style="@style/MyButton"
android:layout_width="match_parent"
@ -177,7 +177,7 @@
android:layout_weight="1"
android:text="1" />
<Button
<TextView
android:id="@+id/btn_2"
style="@style/MyButton"
android:layout_width="match_parent"
@ -185,7 +185,7 @@
android:layout_weight="1"
android:text="2" />
<Button
<TextView
android:id="@+id/btn_3"
style="@style/MyButton"
android:layout_width="match_parent"
@ -193,7 +193,7 @@
android:layout_weight="1"
android:text="3" />
<Button
<TextView
android:id="@+id/btn_plus"
style="@style/MyButton"
android:layout_width="match_parent"
@ -209,7 +209,7 @@
android:layout_weight="2"
android:orientation="horizontal">
<Button
<TextView
android:id="@+id/btn_0"
style="@style/MyButton"
android:layout_width="match_parent"
@ -217,7 +217,7 @@
android:layout_weight="1"
android:text="0" />
<Button
<TextView
android:id="@+id/btn_decimal"
style="@style/MyButton"
android:layout_width="match_parent"
@ -225,7 +225,7 @@
android:layout_weight="1"
android:text="." />
<Button
<TextView
android:id="@+id/btn_clear"
style="@style/MyButton"
android:layout_width="match_parent"
@ -233,7 +233,7 @@
android:layout_weight="1"
android:text="C" />
<Button
<TextView
android:id="@+id/btn_equals"
style="@style/MyButton"
android:layout_width="match_parent"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="widget_text_size">22</integer>
<integer name="widget_text_size">26</integer>
</resources>

View File

@ -8,6 +8,7 @@
<item name="android:fontFamily">sans-serif-light</item>
<item name="android:textAllCaps">false</item>
<item name="android:padding">0dp</item>
<item name="android:gravity">center</item>
<item name="android:layout_margin">@dimen/button_layout_margin</item>
</style>