Schakelaarknop wit via SwitchCompat+thumbTint (werkt in donker thema)
This commit is contained in:
parent
5c90e27b81
commit
ba40cfd76b
4 changed files with 8 additions and 10 deletions
|
|
@ -14,8 +14,8 @@ import android.widget.Toast
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.appcompat.widget.SwitchCompat
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
import kotlinx.coroutines.launch
|
||||
import nl.eddydevink.buschauffeurswekker.core.AlarmScheduler
|
||||
import nl.eddydevink.buschauffeurswekker.core.AlarmSpec
|
||||
|
|
@ -129,7 +129,7 @@ class MainActivity : AppCompatActivity() {
|
|||
card.findViewById<TextView>(R.id.tv_name).text = spec.name
|
||||
val timeView = card.findViewById<TextView>(R.id.tv_time)
|
||||
timeView.text = TIME.format(spec.time)
|
||||
val switch = card.findViewById<MaterialSwitch>(R.id.switch_alarm)
|
||||
val switch = card.findViewById<SwitchCompat>(R.id.switch_alarm)
|
||||
switch.setOnCheckedChangeListener(null)
|
||||
switch.isChecked = !disabled
|
||||
// Heldere statetoestand: blauw = aan, grijs = uit.
|
||||
|
|
|
|||
4
app/src/main/res/color/switch_thumb_wit.xml
Normal file
4
app/src/main/res/color/switch_thumb_wit.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="#FFFFFF" />
|
||||
</selector>
|
||||
|
|
@ -55,11 +55,11 @@
|
|||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/switch_alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="Wekker aan of uit"
|
||||
app:theme="@style/ThemeOverlay.App.SwitchWit" />
|
||||
android:thumbTint="@color/switch_thumb_wit" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
|
@ -14,10 +14,4 @@
|
|||
<item name="android:statusBarColor">@android:color/black</item>
|
||||
<item name="android:navigationBarColor">@android:color/black</item>
|
||||
</style>
|
||||
|
||||
<!-- Alleen voor de wekkerkaarten: de schakelaarknop wit (Material-tokens) -->
|
||||
<style name="ThemeOverlay.App.SwitchWit" parent="">
|
||||
<item name="colorOnSecondaryContainer">@android:color/white</item>
|
||||
<item name="colorSurfaceVariant">@android:color/white</item>
|
||||
</style>
|
||||
</resources>
|
||||
Loading…
Reference in a new issue