Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native rounded image with a border

Tags:

react-native

I want to create a rounded image with a border. If I add borderColor: 'green', borderWidth:1, border is visible only in top left part of the rounded image.

enter image description here

<TouchableHighlight           style={[styles.profileImgContainer, { borderColor: 'green', borderWidth:1 }]}         >     <Image source={{ uri:"https://www.t-nation.com/system/publishing/articles/10005529/original/6-Reasons-You-Should-Never-Open-a-Gym.png" }} style={styles.profileImg} /> </TouchableHighlight>  export default styles = StyleSheet.create({   profileImgContainer: {     marginLeft: 8,     height: 80,     width: 80,     borderRadius: 40,   },   profileImg: {     height: 80,     width: 80,     borderRadius: 40,   }, }); 
like image 876
Matt Avatar asked Apr 29 '18 12:04

Matt


People also ask

How do you use border radius in react?

Use the borderRadius CSS property to set the border radius style of an element in React, e.g. <div style={{border: '1px solid red', borderRadius: '30px'}}> . If you need to style a specific border, use the corresponding property, e.g. borderBottomLeftRadius .

How do I make a circular background in React Native?

To create CSS circles in React Native, we can set the borderRadius style to '50%' . to set the width and height of the View . Then we set borderRadius to '50%' to make it a circle. We set the backgroundColor to add a background color to the circle.

How to add border near to image view in React Native?

In this tutorial we would going to add border near to image view with the use of styles. So let’s get started. Start a fresh React Native project. If you don’t know how then read my this tutorial. Add Image, StyleSheet and View component in import block. Create folder for image inside your project’s folder and put your image in it.

How to add image in React Native with stylesheet?

Inside StyleSheet create two styles Container for complete View and BorderClass for Image. Call css class into both View and Image tag. Complete Source Code. 1. Start a fresh React Native project. If you don’t know how then read my this tutorial. 2. Add Image, StyleSheet and View component in import block. 3.

How to create curved border around an image in HTML?

Inside StyleSheet create two styles Container for complete View and BorderClass for Image. Inside the BorderClass, borderRadius attribute is used to set the border corners and make them curved. // Set content's vertical alignment.

How to create a react native app with React Native init?

We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility. Open the terminal and go to the workspace and run Run the following commands to create a new React Native project


1 Answers

overflow: 'hidden' for images container solves this issue.

like image 77
Matt Avatar answered Sep 19 '22 13:09

Matt