Tcomb-form-native: Colorize or Style Switch component

Created on 8 Mar 2016  路  7Comments  路  Source: gcanti/tcomb-form-native

How is the Switch component (Boolean type) styled ?

Its showing up as a teal color on Android and it seems to be unchangeable ?

Upstream Issue (react-native)

Most helpful comment

My styles.xml in android/res/values

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowIsTranslucent">true</item>
        <!--<item name="switchStyle">@style/Widget.AppCompat.CompoundButton.Switch</item>-->
        <item name="colorControlActivated">#ffffff</item>
    </style>
</resources>

This in android native code will make all controls (checkboxes and radio buttons as well)
white; not perfect, but somewhat works

All 7 comments

The default template contains the official Switch component https://facebook.github.io/react-native/docs/switch.html

There is no style example. I have tried setting color and backgroundColor. The backgroundColor puts a box of color behind the switch. The switch remains the exact same color, grey and teal. I have yet to see an example of a differently colorized switch. Do you have an example ?

https://github.com/gcanti/tcomb-form-native/commit/8a4e24b715f8bc16012f94e440c32d4c5b662622

shows you removed the color setting from the checkbox style because it was throwing an error in the logs. iOS has the tint options.. but not android.. Im guessing this is a RN core issue ?

Hi @jayesbe !

Changing the Switch color isn't supported yet for Android in React Native, check the props http://facebook.github.io/react-native/docs/switch.html#content

It's an upstream issue, will add support for it when the component gets updated.

Got it thanks!

My styles.xml in android/res/values

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowIsTranslucent">true</item>
        <!--<item name="switchStyle">@style/Widget.AppCompat.CompoundButton.Switch</item>-->
        <item name="colorControlActivated">#ffffff</item>
    </style>
</resources>

This in android native code will make all controls (checkboxes and radio buttons as well)
white; not perfect, but somewhat works

Cool @otoinsa! Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelbenker picture michaelbenker  路  3Comments

alexicum picture alexicum  路  6Comments

dvlprmartins picture dvlprmartins  路  4Comments

sibelius picture sibelius  路  4Comments

semirturgay picture semirturgay  路  4Comments