I am using react-native-elements to render an Avatar , I have a image to be shown in a rounded circle Avatar & I would like the image to be in the center of the circle Avatar.
This is what I tried:
<Avatar
size={60}
containerStyle={{backgroundColor: 'black'}}
rounded
ImageComponent={MyImg}
avatarStyle={{justifyContent: 'center', alignItems: 'center'}}
/>
MyImg is a tsx file that is converted from a SVG.
The above code results to MyImg showing on the top left position of the rounded Avatar.
Then I tried:
<Avatar
size={60}
containerStyle={{backgroundColor: 'black', justifyContent: 'center', alignItems: 'center'}}
rounded
ImageComponent={MyImg}
avatarStyle={{justifyContent: 'center', alignItems: 'center'}}
/>
This code makes MyImg disappear. So, I get stuck now.
How to make the image component showing in the center ?
==== more info ====
Here is MyImg.tsx file:
function SvgMyImg(props) {
return (
<Svg width={24} height={24} fill="none" {...props}>
<Path
d="M7 7l10 10M17 7L7 17"
stroke="#fff"
strokeWidth={2}
strokeLinecap="round"
/>
</Svg>
);
}
export default SvgMyImg;
I just import this file e.g. import MyImg from '../assets/images/MyImg'; and use it as the imageComponent of Avatar like my code shows.