Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

border radius on an image react native

// You need overflow set to 'hidden' for the radius to take effect,
// If your images have transparent backgrounds,
	// you'll probably want to have both image and image container
	// components.

const styles = StyleSheet.create({
  imgContainer: {
    width: 10,
    height: 10,
    resizeMode: 'cover',
    borderRadius: 50,
    overflow: 'hidden',
    justifyContent: 'center',
    alignItems: 'center',
  },
  profilePic: {
    width: 8,
    height: 8,
    aspectRatio: 1,
    resizeMode: 'contain',
  },
// Note that the image is slightly smaller than its container
})

// If you don't have transparent backgrounds or known background colors,
	// the above solution will lead to an awkward square in the middle of
	// your circle.
// In this case, you'll have to loose the corners of your image.
const styles = StyleSheet.create({
  imgContainer: {
    justifyContent: 'center',
    alignItems: 'center',
  },
  profilePic: {
    width: 10,
    height: 10,
    aspectRatio: 1,
    resizeMode: 'cover',
    borderRadius: 50,
    overflow: 'hidden',
  },
// If you're not worried about centering your image in a row,
  //the container might not be necessary here.
})

<View style={styles.imgContainer}>
  <Image source={img} style={styles.profilePic} />
</View>
                                 
Comment

react native image border radius not working

add this style "overflow: 'hidden'" for images container solves this issue.
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript list comprehension 
Javascript :: regex or operator 
Javascript :: componentDidmount event on fonctional component 
Javascript :: html css js interview questions 
Javascript :: JavaScript Access Elements of an Array 
Javascript :: aws lambda function setup for node js 
Javascript :: what is node in selenium grid 
Javascript :: window.innerwidth 
Javascript :: inertia js 
Javascript :: npm react animation 
Javascript :: switch statement js 
Javascript :: what is cross browser testing 
Javascript :: last item of array js 
Javascript :: stripe stripe js 
Javascript :: slice() javascript 
Javascript :: JavaScript substr() Syntax 
Javascript :: ex:javascript 
Javascript :: npm windows registry 
Javascript :: js array delete specific element 
Javascript :: react calendar 
Javascript :: js timer 
Javascript :: foreach function into arrow with addeventlistener 
Javascript :: django send and receive image data to react 
Javascript :: AND Or condition in text with bracket how to divide in javascript 
Javascript :: jquery detach and remove 
Javascript :: js palindrome number 
Javascript :: knex muliple like query 
Javascript :: shift reduce parser demo 
Javascript :: kjkjl 
Javascript :: javascript factorial with closure 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =