opaque touchableopacity react native code example
Example 1: touchableopacity as button in react native
import {
TouchableOpacity,
Text,
} from "react-native";
<TouchableOpacity
style={styles.button}
onPress={this.onSubmit}
disabled={!this.state.isFormValid}
>
<Text style={styles.btnText}>Add
</Text>
</TouchableOpacity>
const styles = StyleSheet.create({
button: {
width: 200,
marginTop: 20,
backgroundColor: "green",
padding: 15,
borderRadius: 50,
},
btnText: {
color: "white",
fontSize: 20,
justifyContent: "center",
textAlign: "center",
},
});
Example 2: decrease touchableopacity in react native
setOpacityTo((value: number), (duration: number));