首页 > 解决方案 > 使用渐变颜色反应原生 ActivityIndi​​cator

问题描述

可以在 android 上创建具有渐变颜色的 ActivityIndi​​cator 吗?我尝试使用 react-native-linear-gradient 库并像这样实现:

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

但这是行不通的。

标签: androidreact-nativelinear-gradientsactivity-indicator

解决方案


这是不可能的,因为color道具必须是字符串值https://reactnative.dev/docs/activityindicator#color但您尝试传递一个组件。

您可以尝试使用自定义组件,例如这里https://github.com/oblador/react-native-progress/issues/144#issuecomment-481419746


推荐阅读