I am trying to achieve make dynamic size cell for a simple chat view on React Native. The question and answers in Flex box dynamic width and height link helped me much but I did not make apply dynamic width to the cells. Here is the cell code of myself.
class ChatCell extends React.Component {
render() {
return (
<View style={{ marginTop: 10, marginBottom: 10 }}>
<View
style={{
backgroundColor: "rgba(245,25,116,1)",
borderBottomLeftRadius: 12,
borderTopLeftRadius: 12,
borderTopRightRadius: 12,
marginLeft: 100,
marginRight: 15,
padding: 5,
flex: -1
}}
>
<Text
style={{
padding: 5,
textAlign: "right",
fontFamily: "inter-medium",
color: "white"
}}
>
{this.props.message}
</Text>
</View>
</View>
);
}
}
And here is the screenshot of what I made.
My problem is when I enter a simple message such as 'OK!' it must be stretch to its width. So how can I achieve it, like giving minimum width?
I tried to add alignSelf:'stretch' but it did not work for me.
What is the missing part of what I am doing wrong?
Thanks,
