Alf*_*Woo 3 android android-support-library
我需要更改SwitchCompat的轨道颜色.我试过这个,但它对我不起作用.这是我的XML文件的代码
<android.support.v7.widget.SwitchCompat
android:id="@+id/sc_push"
style="@style/switchStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:theme="@style/switchStyle"
app:theme="@style/switchStyle" />
Run Code Online (Sandbox Code Playgroud)
这是我的style.xml文件
<style name="switchStyle">
<item name="colorControlActivated">@color/red</item>
<item name="android:colorForeground">@color/gray</item>
</style>
Run Code Online (Sandbox Code Playgroud)
看来问题是什么?
另外,我无法更改活动的颜色或基本应用程序的颜色.我必须改变这个单一视图的颜色.
Jik*_*iks 12
试试这个代码.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<!-- Active thumb color & Active track color(30% transparency) -->
<item name="colorControlActivated">@color/theme</item>
<!-- Inactive thumb color -->
<item name="colorSwitchThumbNormal">@color/grey300</item>
<!-- Inactive track color(30% transparency) -->
<item name="android:colorForeground">@color/grey600</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6810 次 |
| 最近记录: |