【发布时间】:2020-08-19 07:29:07
【问题描述】:
在我的应用程序中,第一个活动是一个选择器,我可以在其中选择 3 个按钮:红色、绿色、黄色。当我选择一个按钮时,会显示一个带有 SwitchMaterial 的新活动。现在我想更改 colorControlActivated,如果我选择了红色按钮,则开关颜色为红色,绿色按钮为绿色,依此类推。我该怎么做?
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/profile_setting_switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:theme="@style/SwitchTecnoTheme"
app:layout_constraintBottom_toBottomOf="@id/profile_setting_1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/profile_setting_1" />
<style name="SwitchTecnoTheme" >
<item name="colorControlActivated">@color/tecno_brand_color</item>
</style>
【问题讨论】:
标签: android kotlin android-styles material-components-android android-switch