Search code examples
androidreact-nativelinear-gradientsactivity-indicator

React Native ActivityIndicator with gradient color


It is possible to create ActivityIndicator with gradient color on android ? I tried use react-native-linear-gradient library and implement like this:

    <ActivityIndicator
                    size="large"
                    color={
                        <LinearGradient
                            colors={['#37ca93', '#4a5de2']}
                            start={{ x: 0, y: 0 }}
                            end={{ x: 1, y: 0 }}
                        />
                    }
                />

but it isn't work.


Solution

  • It's impossible, because a color prop must be a string value https://reactnative.dev/docs/activityindicator#color but you tried pass a component.

    You can try use custom component, example here https://github.com/oblador/react-native-progress/issues/144#issuecomment-481419746