react-native-vector-icons
react-native-vector-icons copied to clipboard
Incorrect vertical alignment of material community icons on iOS
- [x] Review the documentation: https://github.com/oblador/react-native-vector-icons
- [x] Search for existing issues (including closed issues): https://github.com/oblador/react-native-vector-icons/issues
Environment
System:
OS: macOS 10.15.4
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 1.21 GB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: ^0.60.5 => 0.60.6
Description
With code like below, on Android the icon is perfectly centered in the View, whereas on iOS the icon is shifted a couple of px up from where it should be. We're mixing this with a custom icon font, so it's really obvious that certain icons are misaligned in a toolbar for example.
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
const MyComponent = () => {
return (
<View style={{width: 48, height: 48, alignItems: 'center', justifyContent: 'center', backgroundColor: 'red'}}>
<MaterialIcon name="close" size={24} color="#000" />
</View>
)
}
Android | iOS |
---|---|
![]() |
![]() |
Ignoring the crappy quality of the screenshot, you can see it's centered perfectly | On iOS there is a small offset |
Reproducible Demo
Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve
See above but let me know if you need a full reproduction repo.
I have the same problem. Any news?
hey @mjmasn
While I can see that there is an offset in your screenshots I can't reproduce it on my side. I believe this is something to do with your views?
My screenshot is taken on IOS Simulator iPhone 11. The icon container is in black and the icon itself is white and I could not see any offsets.
@szholdiyarov there's 8px above the X and 10px below it in your image. It's clearer if you zoom in.
![Screenshot 2020-04-27 at 14 56 43](https://user-images.githubusercontent.com/2977095/80380392-6c802c80-8897-11ea-83c7-39c67f361f3c.png)
I have the same issues. Android is fine, its just iOS.
Android: perfectly centered
iOS: not centered
Same issue with Ionicons on ios only. Has anyone found a solution?
@zabojad
I fixed it by adding additional paddingTop
and paddingLeft
on iOS only