أحاول استخدام pointerEvents={'none'}
على مكوِّن الصورة ، لكنه لا يعمل على Android. إنه فعال على iOS.
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Memory: 141.91 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.1.0 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 24, 26, 27, 28
Build Tools: 26.0.2, 27.0.3, 28.0.2, 28.0.3
System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-28 | Intel x86 Atom_64
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
export default class GeneralBackground extends PureComponent {
render() {
return (
<View style={styles.container}>
{this.props.children}
<Image
source={myImage}
style={styles.image}
pointerEvents={'none'} // Does not work on Android.
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.theme
},
image: {
width: 160,
resizeMode: 'stretch',
alignSelf: 'center',
position: 'absolute'
}
});
أتوقع أن this.props.children
مثل مكون الزر يمكن أن يعمل ولكن ليس الصورة أعلاه. ولكن يمكن أن يعمل على نظام التشغيل iOS عن طريق الاختبار ، فشل Android. هل استخدمته عن طريق الخطأ؟ أعتقد أنه ربما خطأ.
أي شخص يعرف ذلك؟ شكرا جزيلا مقدما.
مرحبا @ Amos729 ،
يبدو أن الخاصية pointerEvents
غير متوفرة في المكون Image
: البحث في pointerEvents
على https://facebook.github.io/react-native/docs/image أسفر لا شيئ.
أعتقد أنه متاح فقط لمكونات View
: https://facebook.github.io/react-native/docs/view#pointerevents
القيام بشيء من هذا القبيل
<View style={styles2.image} pointerEvents={'none'}>
<Image source={myImage} />
</View>
جعل الأطفال Button
قابل للنقر على Android.
امل ان يساعد!
RobinCsl لقد جربت ما قلته للتو. إنها مفيدة حقًا لكل من نظامي Android و iOS.
شكرا جزيلا لك.
التعليق الأكثر فائدة
مرحبا @ Amos729 ،
يبدو أن الخاصية
pointerEvents
غير متوفرة في المكونImage
: البحث فيpointerEvents
على https://facebook.github.io/react-native/docs/image أسفر لا شيئ.أعتقد أنه متاح فقط لمكونات
View
: https://facebook.github.io/react-native/docs/view#pointereventsالقيام بشيء من هذا القبيل
جعل الأطفال
Button
قابل للنقر على Android.امل ان يساعد!