Open dabit3 opened 6 years ago
On Android icons are resized automatically, on iOS this does not happen and it ends up like this:
We had the same problem. For fix in IOS, we set the icons for size 25x25
What I have read indicates that on Android icon size is automatically set by the native component that RNN uses for the bottom tabs.
On iOS we have a property scale
that is not the v2 docs
bottomTab: {
icon: {
scale: 1.5, // the higher the number the smaller the icon
uri: 'person'
},
text: 'PERFIL'
}
hope this helps
@andres-gr I've tried your workaround on latest version (2.8.0
), but it seems it doesn't work.
@LRNZ09 had no idea, it works on version 2.7.1
Having the same issue...
just add the following line for icon size.. at react-native-navigation>lib>android>src>app>main>res>values>dimen.xml
default icon size 24dp
Had the same issue, i resize the image myself. That fixed my issue.
Hi @andres-gr,
I tried to export a small 30px png icon and use it directly with icon: require('path')
but because it's so small, the image quality is very bad, that's why I really want to use your approach (I export a large image with x3 quality), then use the scale to make it smaller, however I cannot make it work. The exceptionpathExtension cannot be nil
was thrown. So I really want to ask how can you define the uri path in this case.
bottomTab: {
icon: {
scale: 1.5, // the higher the number the smaller the icon
uri: 'person'
},
text: 'PERFIL'
}
I mean if I store the image in the app folder assets/images/icon.png
then when I tried to use
bottomTab: {
icon: {
scale: 3,
uri: '/assets/images/icon.png',
},
},
it will raise the error pathExtension cannot be nil
. I already tried different kind of paths (../assets) but none of them work. Could you please help me to clarify this, thank you
@nenjamin2405 I believe the solution I posted only works on svg icon files that have been added to the native assets.
That's how you can call them by using only their name, without a path or file extension. And also why the scale property affects them.
@andres-gr many thanks for your reply, I don't have much experience about adding svg icon files to native assets, could you please give me some advices or related articles of how to implement that in react native? Really appreciate it
@nenjamin2405 You can find it very quickly on Google or stack overflow, I don't have a reference on hand right now, it's been a long time since I have worked with React native.
A tip I can give you us that for iOS, for some odd reason, you need to add svg icons as pdf files.
You can also search for a command line utility that transforms .svg
files to .pdf
files.
@andres-gr Many thanks, really appreciate your response, I'll investigate about it :D
For those who have the same problem, I followed this topic in StackOverflow and it works: https://stackoverflow.com/questions/57920195/set-icon-size-in-bottomtab-configuration-react-native-navigation
Basically, all you need to do is:
options: {
bottomTab: {
icon: {
scale: 3,
uri: 'your-icon',
},
selectedIcon: {
scale: 3,
uri: 'your-icon-selected',
},
},
},
Open XCode Go to Images.xcassets Drag your image to that folder
for android you can use your local images directory
and for ios, you can use the name of the image the you put inside that Images.xcassets
folder
{
bottomTab: {
...(Platform.OS === 'ios'
? {
icon: {
uri: 'cart-icon',
scale: 3
},
}
: {
icon: require('../assets/cart-icon.png'),
}),
}
}
Issue Description
Right now, there is no way to set the size of icons in the bottomTab configuration. I think it would be nice to either be able to pass in an Image component here with its own config / styling, or to have something like iconSize or iconStyle prop to be able to have control over the size of the icon.
Steps to Reproduce / Code Snippets / Screenshots
Environment