我尝试使用“打开”颜色,“颜色”,“颜色”来更改开关的颜色。两种方式均无效。
答案 0 :(得分:1)
对于Android,您可以使用此主题设置轨迹和拇指色调的颜色:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyThemeActionbar" parent="Theme.AppCompat">
<!-- switch -->
<item name="switchStyle">@style/newSwitchStyle</item>
</style>
<style name="newSwitchStyle" parent="android:Widget.CompoundButton">
<item name="track">@drawable/abc_switch_track_mtrl_alpha</item>
<item name="android:thumb">@drawable/abc_switch_thumb_material</item>
<item name="switchTextAppearance">@style/TextAppearance.AppCompat.Widget.Switch</item>
<item name="android:background">?attr/controlBackground</item>
<item name="showText">false</item>
<item name="switchPadding">@dimen/abc_switch_padding</item>
<item name="android:textOn">@string/abc_capital_on</item>
<item name="android:textOff">@string/abc_capital_off</item>
<!-- track and button -->
<item name="trackTint">#00f</item>
<item name="thumbTint">#f00</item>
</style>
</resources>
platform/android/res/values/mytheme.xml
var win = Ti.UI.createWindow({theme: "Theme.MyThemeActionbar",});
或
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.MyThemeActionbar"/>
</manifest>
</android>
检查:http://docs.appcelerator.com/platform/latest/#!/guide/Android_Themes用于应用/添加主题