我有一个特定的滑块。我该如何设计它们?我使用react-native-slider。这是我的代码(我修改了本示例中的代码):
render() {
const sliderStyle = {
sliderDummy: {
width: 200,
height: 80,
position: 'absolute',
},
sliderReal: {
backgroundColor: colors.primary,
width: (this.state.slideValue / 50) * 200,
height: 80,
borderBottomRightRadius: 100,
borderTopRightRadius: 100
}
}
return (
<View style={styles.container}>
<View style={{overflow: 'hidden'}}>
<View style={{flexDirection: 'row', position: 'absolute'}}>
<View style={sliderStyle.sliderDummy}></View>
<View style={sliderStyle.sliderReal}></View>
</View>
<Slider
style={{width: 200, height: 80}}
minimumValue={0}
maximumValue={50}
value={this.state.slideValue}
onValueChange={(value)=> this.setState({ slideValue: value}) }
maximumTrackTintColor='transparent'
minimumTrackTintColor='transparent'
thumbStyle={styles.thumb}
/>
<Text>{this.state.slideValue}</Text>
</View>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
当我向右滑动时,轨道中间出现圆角:
但我需要这样的东西: …