im new in React native, i want to display image, attributed text inside Text programmatically, but after read React Native document i can not find anything that related to attributed text
In android, it's call SpannableString, and it's equavilent to AttributedString in IOS, but I can not find the same in React Native
Can anyone guide me some great library/document? Thank in advance
CodePudding user response:
Try this package react-native-spannable-string
CodePudding user response:
your question is unclear but if i've gotten it correctly you want to display text on top of an image. If thats the case use Imagebackground
import React from "react";
import { ImageBackground, StyleSheet, Text, View } from "react-native";
const image = { uri: "https://reactjs.org/logo-og.png" };
const App = () => (
<View style={styles.container}>
<ImageBackground source={image} resizeMode="cover" style={styles.image}>
<Text style={styles.text}>The text you want to display</Text>
</ImageBackground>
</View>
);
const styles = StyleSheet.create({
container: {
flex: 1,
},
image: {
flex: 1,
justifyContent: "center"
},
text: {
color: "white",
fontSize: 42,
lineHeight: 84,
fontWeight: "bold",
textAlign: "center",
backgroundColor: "#000000c0"
}
});
export default App;