What does TouchableHighlight do and when do you use it?
What does TouchableHighlight do and when do you use it?
What does TouchableHighlight do?
TouchableHighlight is a React Native component that wraps around a view to make it respond to touch events. When a user presses down on the TouchableHighlight component, the opacity of the wrapped view decreases, allowing the underlay color to show through. This provides visual feedback to the user, indicating that the touch event has been registered. The component must have exactly one child; if multiple children are needed, they should be wrapped in a single View component.
Key Properties:
onPress: Function to be called when the touch is released.disabled: If true, disables all interactions.style: Specifies the style of the TouchableHighlight component.activeOpacity: Specifies the opacity value of the wrapped view when the touch is active (default is 0.85).underlayColor: Specifies the color of the underlay that is shown when the touch is active.Example Usage:
import React from 'react';
import { StyleSheet, Text, View, TouchableHighlight, Alert } from 'react-native';
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.