Add a custom image or custom background color as chat background

247 Views Asked by At

I am using react-native-gifted-chat, I want to add a background image (or at least a background color) for the chat but I cannot seem to find the prop. Can someone help?

My current implementation is

    <GiftedChat
      messages={messagesState}
      onSend={(message: IMessage[]) => onSend(message)}
      user={{
        _id: 1,
      }}
      renderAvatarOnTop
      isTyping={mutationLoading}
      onInputTextChanged={debouncedOnInputTextChanged}
      listViewProps={{
        onEndReached: onFetchMore,
      }}
    />
    
2

There are 2 best solutions below

1
USMAN QAYYUM On

messageContainerStyle={{backgroundColor: 'red'}} // add this prop in gifted Chat

0
TheGeek On

You can use <ImageBackground> component from react-native.

Example Usage:

<ImageBackground resizeMode='cover' imageStyle={{ opacity: 0.07 }} source={require('../../../assets/chatBackground.png')} style={{ flex: 1 }}>    
    <GiftedChat ...props/>
</ImageBackground >