How to set shadows in React Native for android?
up vote
37
down vote
favorite
Hi am trying to set a shadow for my fab but my attempts has failed so far i tried setting shadow props but that is for ios only so i tried to play with elevation property but it doesn't look right.
Here's what i tried
<View style=width: 56, height: 56, elevation: 2, borderRadius: 28, marginBottom: 3, backgroundColor: 'rgba(231,76,60,1)'></View>
What i need to achieve

react-native
add a comment |
up vote
37
down vote
favorite
Hi am trying to set a shadow for my fab but my attempts has failed so far i tried setting shadow props but that is for ios only so i tried to play with elevation property but it doesn't look right.
Here's what i tried
<View style=width: 56, height: 56, elevation: 2, borderRadius: 28, marginBottom: 3, backgroundColor: 'rgba(231,76,60,1)'></View>
What i need to achieve

react-native
add a comment |
up vote
37
down vote
favorite
up vote
37
down vote
favorite
Hi am trying to set a shadow for my fab but my attempts has failed so far i tried setting shadow props but that is for ios only so i tried to play with elevation property but it doesn't look right.
Here's what i tried
<View style=width: 56, height: 56, elevation: 2, borderRadius: 28, marginBottom: 3, backgroundColor: 'rgba(231,76,60,1)'></View>
What i need to achieve

react-native
Hi am trying to set a shadow for my fab but my attempts has failed so far i tried setting shadow props but that is for ios only so i tried to play with elevation property but it doesn't look right.
Here's what i tried
<View style=width: 56, height: 56, elevation: 2, borderRadius: 28, marginBottom: 3, backgroundColor: 'rgba(231,76,60,1)'></View>
What i need to achieve

react-native
react-native
asked Dec 25 '16 at 9:46
Ibrahim Ahmed
5062627
5062627
add a comment |
add a comment |
11 Answers
11
active
oldest
votes
up vote
55
down vote
accepted
UPDATE
Adding css property elevation: 1 renders shadow in Android without installing any 3rd party library. See other answers.
--
One way to get shadows for android is to install react-native-shadow
Example from the readme:
import React, Component from 'react' import
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight from 'react-native'
import BoxShadow from 'react-native-shadow'
export default class VideoCell extends Component
render = () =>
const shadowOpt =
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:marginVertical:5
return (
<BoxShadow setting=shadowOpt>
<TouchableHighlight style=
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden">
…………………………
</TouchableHighlight>
</BoxShadow>
)
2
Adding css propertyelevation: 1renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52
– Guy
Jan 15 at 3:41
Be careful when usingelevationas it won't respect your settings forshadow, such as the color and offset.
– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
add a comment |
up vote
65
down vote
Another solution without using a third-party library is using elevation.
Pulled from react-native documentation.
https://facebook.github.io/react-native/docs/view.html
(Android-only) Sets the elevation of a view, using Android's
underlying elevation API. This adds a drop shadow to the item and
affects z-order for overlapping views. Only supported on Android 5.0+,
has no effect on earlier versions.
elevation will go into the style property and it can be implemented like so.
<View style= elevation: 2 >
children
</View>
The higher the elevation, the bigger the shadow. Hope this helps!
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
|
show 1 more comment
up vote
29
down vote
You can try
//ios
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset:
height: 0,
width: 0
,
//android
elevation: 1
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
add a comment |
up vote
5
down vote
Just use 'elevation' property to get shadow in android. something like below
const Header = () =>
// const textStyle, viewStyle = styles;
return (
<View style=styles.viewStyle>
<Text style=styles.textStyle>Albums</Text>
</View>
)
const styles =
viewStyle:
backgroundColor:'#f8f8f8',
justifyContext:'center',
alignItems: 'center',
padding:16,
elevation: 2
add a comment |
up vote
2
down vote
The following will help you to give each Platform the styling you want:
import Text, View, Platform from 'react-native';
......
<View style=styles.viewClass></View>
......
const styles =
viewClass:
justifyContent: 'center',
alignItems: 'center',
height: 60,
...Platform.select(
ios:
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
,
android:
elevation: 1
,
),
;
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
add a comment |
up vote
1
down vote
for an android screen you can use this property elevation.
for example :
HeaderView:
backgroundColor:'#F8F8F8',
justifyContent:'center',
alignItems:'center',
height:60,
paddingTop:15,
//Its for IOS
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
// its for android
elevation: 5,
position:'relative',
,
add a comment |
up vote
0
down vote
elevation still no work in Expo v30 && React-native v0.55.4.
I have tried the all answers here.
Also, don't try react-native-shadow - their shadow rendering is terrible.
So, I am continuing the research.
add a comment |
up vote
0
down vote
I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview
import CardView from 'react-native-cardview'
<CardView
cardElevation=2
cardMaxElevation=2
cornerRadius=5>
<Text>
Elevation 0
</Text>
</CardView>

add a comment |
up vote
0
down vote
In short, you can't do that in android, because if you see the docs about shadow only Support IOS see doc
The best option you can install 3rd party react-native-shadow
add a comment |
up vote
0
down vote
Set elevation: 3 and you should see the shadow in bottom of component without a 3rd party lib. At least in RN 0.57.4
add a comment |
up vote
0
down vote
I had the same problem shadow/elevation not showing on Android with elevation:2. Then i noticed that the view element is fool width, so I added margin:2 to the view element and elevation properly appeared.
Style:
margin: 2,
shadowColor: '#000',
shadowOffset:
width: 0,
height: 1
,
shadowOpacity: 0.2,
shadowRadius: 1.41,
elevation: 2
Android:
iOS:
add a comment |
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
55
down vote
accepted
UPDATE
Adding css property elevation: 1 renders shadow in Android without installing any 3rd party library. See other answers.
--
One way to get shadows for android is to install react-native-shadow
Example from the readme:
import React, Component from 'react' import
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight from 'react-native'
import BoxShadow from 'react-native-shadow'
export default class VideoCell extends Component
render = () =>
const shadowOpt =
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:marginVertical:5
return (
<BoxShadow setting=shadowOpt>
<TouchableHighlight style=
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden">
…………………………
</TouchableHighlight>
</BoxShadow>
)
2
Adding css propertyelevation: 1renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52
– Guy
Jan 15 at 3:41
Be careful when usingelevationas it won't respect your settings forshadow, such as the color and offset.
– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
add a comment |
up vote
55
down vote
accepted
UPDATE
Adding css property elevation: 1 renders shadow in Android without installing any 3rd party library. See other answers.
--
One way to get shadows for android is to install react-native-shadow
Example from the readme:
import React, Component from 'react' import
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight from 'react-native'
import BoxShadow from 'react-native-shadow'
export default class VideoCell extends Component
render = () =>
const shadowOpt =
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:marginVertical:5
return (
<BoxShadow setting=shadowOpt>
<TouchableHighlight style=
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden">
…………………………
</TouchableHighlight>
</BoxShadow>
)
2
Adding css propertyelevation: 1renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52
– Guy
Jan 15 at 3:41
Be careful when usingelevationas it won't respect your settings forshadow, such as the color and offset.
– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
add a comment |
up vote
55
down vote
accepted
up vote
55
down vote
accepted
UPDATE
Adding css property elevation: 1 renders shadow in Android without installing any 3rd party library. See other answers.
--
One way to get shadows for android is to install react-native-shadow
Example from the readme:
import React, Component from 'react' import
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight from 'react-native'
import BoxShadow from 'react-native-shadow'
export default class VideoCell extends Component
render = () =>
const shadowOpt =
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:marginVertical:5
return (
<BoxShadow setting=shadowOpt>
<TouchableHighlight style=
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden">
…………………………
</TouchableHighlight>
</BoxShadow>
)
UPDATE
Adding css property elevation: 1 renders shadow in Android without installing any 3rd party library. See other answers.
--
One way to get shadows for android is to install react-native-shadow
Example from the readme:
import React, Component from 'react' import
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight from 'react-native'
import BoxShadow from 'react-native-shadow'
export default class VideoCell extends Component
render = () =>
const shadowOpt =
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:marginVertical:5
return (
<BoxShadow setting=shadowOpt>
<TouchableHighlight style=
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden">
…………………………
</TouchableHighlight>
</BoxShadow>
)
edited Jan 15 at 8:01
answered Jan 4 '17 at 6:40
FuzzyTree
26.1k22954
26.1k22954
2
Adding css propertyelevation: 1renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52
– Guy
Jan 15 at 3:41
Be careful when usingelevationas it won't respect your settings forshadow, such as the color and offset.
– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
add a comment |
2
Adding css propertyelevation: 1renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52
– Guy
Jan 15 at 3:41
Be careful when usingelevationas it won't respect your settings forshadow, such as the color and offset.
– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
2
2
Adding css property
elevation: 1 renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52– Guy
Jan 15 at 3:41
Adding css property
elevation: 1 renders shadow in Android without installing any 3rd party library. I tested it with React Native 0.52– Guy
Jan 15 at 3:41
Be careful when using
elevation as it won't respect your settings for shadow, such as the color and offset.– cseelus
Apr 5 at 17:55
Be careful when using
elevation as it won't respect your settings for shadow, such as the color and offset.– cseelus
Apr 5 at 17:55
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
this lib, how to do if I don't know the specify width height of children. . . cuz it require.
– Leang Socheat
Oct 23 at 3:03
add a comment |
up vote
65
down vote
Another solution without using a third-party library is using elevation.
Pulled from react-native documentation.
https://facebook.github.io/react-native/docs/view.html
(Android-only) Sets the elevation of a view, using Android's
underlying elevation API. This adds a drop shadow to the item and
affects z-order for overlapping views. Only supported on Android 5.0+,
has no effect on earlier versions.
elevation will go into the style property and it can be implemented like so.
<View style= elevation: 2 >
children
</View>
The higher the elevation, the bigger the shadow. Hope this helps!
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
|
show 1 more comment
up vote
65
down vote
Another solution without using a third-party library is using elevation.
Pulled from react-native documentation.
https://facebook.github.io/react-native/docs/view.html
(Android-only) Sets the elevation of a view, using Android's
underlying elevation API. This adds a drop shadow to the item and
affects z-order for overlapping views. Only supported on Android 5.0+,
has no effect on earlier versions.
elevation will go into the style property and it can be implemented like so.
<View style= elevation: 2 >
children
</View>
The higher the elevation, the bigger the shadow. Hope this helps!
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
|
show 1 more comment
up vote
65
down vote
up vote
65
down vote
Another solution without using a third-party library is using elevation.
Pulled from react-native documentation.
https://facebook.github.io/react-native/docs/view.html
(Android-only) Sets the elevation of a view, using Android's
underlying elevation API. This adds a drop shadow to the item and
affects z-order for overlapping views. Only supported on Android 5.0+,
has no effect on earlier versions.
elevation will go into the style property and it can be implemented like so.
<View style= elevation: 2 >
children
</View>
The higher the elevation, the bigger the shadow. Hope this helps!
Another solution without using a third-party library is using elevation.
Pulled from react-native documentation.
https://facebook.github.io/react-native/docs/view.html
(Android-only) Sets the elevation of a view, using Android's
underlying elevation API. This adds a drop shadow to the item and
affects z-order for overlapping views. Only supported on Android 5.0+,
has no effect on earlier versions.
elevation will go into the style property and it can be implemented like so.
<View style= elevation: 2 >
children
</View>
The higher the elevation, the bigger the shadow. Hope this helps!
answered Jan 6 '17 at 21:34
Ajackster
1,2781612
1,2781612
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
|
show 1 more comment
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
why elevation attribute is written inside 2 braces?
– divine
Jun 24 '17 at 7:52
5
5
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
@divine the outer bracket is for JS interpolation, the inner is for an object
– Asaf David
Jun 25 '17 at 7:28
3
3
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
This only does a shadow on the bottom of a view, it doesn't allow you to do shadows on the other sides
– Erich
Aug 31 '17 at 18:41
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
Correct, there are many things iOS handles better when using react-native and shadows are one of them.
– Ajackster
Aug 31 '17 at 20:25
2
2
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
Note: this only works in Android 5.0+
– Muhammad Riyaz
Sep 8 '17 at 10:31
|
show 1 more comment
up vote
29
down vote
You can try
//ios
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset:
height: 0,
width: 0
,
//android
elevation: 1
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
add a comment |
up vote
29
down vote
You can try
//ios
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset:
height: 0,
width: 0
,
//android
elevation: 1
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
add a comment |
up vote
29
down vote
up vote
29
down vote
You can try
//ios
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset:
height: 0,
width: 0
,
//android
elevation: 1
You can try
//ios
shadowOpacity: 0.3,
shadowRadius: 3,
shadowOffset:
height: 0,
width: 0
,
//android
elevation: 1
edited Jan 15 at 7:46
Guy
1,30611526
1,30611526
answered Aug 2 '17 at 2:26
lam luu
42455
42455
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
add a comment |
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
Elevation does not create a large enough or configurable shadow for android - react-native-shadow seems like the best option
– evanjmg
Mar 6 at 12:02
add a comment |
up vote
5
down vote
Just use 'elevation' property to get shadow in android. something like below
const Header = () =>
// const textStyle, viewStyle = styles;
return (
<View style=styles.viewStyle>
<Text style=styles.textStyle>Albums</Text>
</View>
)
const styles =
viewStyle:
backgroundColor:'#f8f8f8',
justifyContext:'center',
alignItems: 'center',
padding:16,
elevation: 2
add a comment |
up vote
5
down vote
Just use 'elevation' property to get shadow in android. something like below
const Header = () =>
// const textStyle, viewStyle = styles;
return (
<View style=styles.viewStyle>
<Text style=styles.textStyle>Albums</Text>
</View>
)
const styles =
viewStyle:
backgroundColor:'#f8f8f8',
justifyContext:'center',
alignItems: 'center',
padding:16,
elevation: 2
add a comment |
up vote
5
down vote
up vote
5
down vote
Just use 'elevation' property to get shadow in android. something like below
const Header = () =>
// const textStyle, viewStyle = styles;
return (
<View style=styles.viewStyle>
<Text style=styles.textStyle>Albums</Text>
</View>
)
const styles =
viewStyle:
backgroundColor:'#f8f8f8',
justifyContext:'center',
alignItems: 'center',
padding:16,
elevation: 2
Just use 'elevation' property to get shadow in android. something like below
const Header = () =>
// const textStyle, viewStyle = styles;
return (
<View style=styles.viewStyle>
<Text style=styles.textStyle>Albums</Text>
</View>
)
const styles =
viewStyle:
backgroundColor:'#f8f8f8',
justifyContext:'center',
alignItems: 'center',
padding:16,
elevation: 2
answered Nov 11 '17 at 17:51
SameerShaik
201516
201516
add a comment |
add a comment |
up vote
2
down vote
The following will help you to give each Platform the styling you want:
import Text, View, Platform from 'react-native';
......
<View style=styles.viewClass></View>
......
const styles =
viewClass:
justifyContent: 'center',
alignItems: 'center',
height: 60,
...Platform.select(
ios:
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
,
android:
elevation: 1
,
),
;
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
add a comment |
up vote
2
down vote
The following will help you to give each Platform the styling you want:
import Text, View, Platform from 'react-native';
......
<View style=styles.viewClass></View>
......
const styles =
viewClass:
justifyContent: 'center',
alignItems: 'center',
height: 60,
...Platform.select(
ios:
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
,
android:
elevation: 1
,
),
;
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
add a comment |
up vote
2
down vote
up vote
2
down vote
The following will help you to give each Platform the styling you want:
import Text, View, Platform from 'react-native';
......
<View style=styles.viewClass></View>
......
const styles =
viewClass:
justifyContent: 'center',
alignItems: 'center',
height: 60,
...Platform.select(
ios:
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
,
android:
elevation: 1
,
),
;
The following will help you to give each Platform the styling you want:
import Text, View, Platform from 'react-native';
......
<View style=styles.viewClass></View>
......
const styles =
viewClass:
justifyContent: 'center',
alignItems: 'center',
height: 60,
...Platform.select(
ios:
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
,
android:
elevation: 1
,
),
;
answered Jul 12 at 9:36
Mohammed Alawneh
5113
5113
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
add a comment |
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
2
2
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
It's not needed to specify the platform since in iOS elevation property will be ignored
– cody
Jul 26 at 22:42
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
@cody yes, you are right! but my example shows how to set styles for different platforms.
– Mohammed Alawneh
Jul 29 at 7:12
add a comment |
up vote
1
down vote
for an android screen you can use this property elevation.
for example :
HeaderView:
backgroundColor:'#F8F8F8',
justifyContent:'center',
alignItems:'center',
height:60,
paddingTop:15,
//Its for IOS
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
// its for android
elevation: 5,
position:'relative',
,
add a comment |
up vote
1
down vote
for an android screen you can use this property elevation.
for example :
HeaderView:
backgroundColor:'#F8F8F8',
justifyContent:'center',
alignItems:'center',
height:60,
paddingTop:15,
//Its for IOS
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
// its for android
elevation: 5,
position:'relative',
,
add a comment |
up vote
1
down vote
up vote
1
down vote
for an android screen you can use this property elevation.
for example :
HeaderView:
backgroundColor:'#F8F8F8',
justifyContent:'center',
alignItems:'center',
height:60,
paddingTop:15,
//Its for IOS
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
// its for android
elevation: 5,
position:'relative',
,
for an android screen you can use this property elevation.
for example :
HeaderView:
backgroundColor:'#F8F8F8',
justifyContent:'center',
alignItems:'center',
height:60,
paddingTop:15,
//Its for IOS
shadowColor: '#000',
shadowOffset: width: 0, height: 2 ,
shadowOpacity: 0.2,
// its for android
elevation: 5,
position:'relative',
,
edited Aug 29 at 16:13
Mahdi Bashirpour
1,4952828
1,4952828
answered May 27 at 7:57
Aras
12216
12216
add a comment |
add a comment |
up vote
0
down vote
elevation still no work in Expo v30 && React-native v0.55.4.
I have tried the all answers here.
Also, don't try react-native-shadow - their shadow rendering is terrible.
So, I am continuing the research.
add a comment |
up vote
0
down vote
elevation still no work in Expo v30 && React-native v0.55.4.
I have tried the all answers here.
Also, don't try react-native-shadow - their shadow rendering is terrible.
So, I am continuing the research.
add a comment |
up vote
0
down vote
up vote
0
down vote
elevation still no work in Expo v30 && React-native v0.55.4.
I have tried the all answers here.
Also, don't try react-native-shadow - their shadow rendering is terrible.
So, I am continuing the research.
elevation still no work in Expo v30 && React-native v0.55.4.
I have tried the all answers here.
Also, don't try react-native-shadow - their shadow rendering is terrible.
So, I am continuing the research.
answered Sep 24 at 10:29
Niklavr
19113
19113
add a comment |
add a comment |
up vote
0
down vote
I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview
import CardView from 'react-native-cardview'
<CardView
cardElevation=2
cardMaxElevation=2
cornerRadius=5>
<Text>
Elevation 0
</Text>
</CardView>

add a comment |
up vote
0
down vote
I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview
import CardView from 'react-native-cardview'
<CardView
cardElevation=2
cardMaxElevation=2
cornerRadius=5>
<Text>
Elevation 0
</Text>
</CardView>

add a comment |
up vote
0
down vote
up vote
0
down vote
I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview
import CardView from 'react-native-cardview'
<CardView
cardElevation=2
cardMaxElevation=2
cornerRadius=5>
<Text>
Elevation 0
</Text>
</CardView>

I have implemented CardView for react-native with elevation, that support android(All version) and iOS. Let me know is it help you or not. https://github.com/Kishanjvaghela/react-native-cardview
import CardView from 'react-native-cardview'
<CardView
cardElevation=2
cardMaxElevation=2
cornerRadius=5>
<Text>
Elevation 0
</Text>
</CardView>

answered Sep 25 at 8:10
Kishan Vaghela
5,36122751
5,36122751
add a comment |
add a comment |
up vote
0
down vote
In short, you can't do that in android, because if you see the docs about shadow only Support IOS see doc
The best option you can install 3rd party react-native-shadow
add a comment |
up vote
0
down vote
In short, you can't do that in android, because if you see the docs about shadow only Support IOS see doc
The best option you can install 3rd party react-native-shadow
add a comment |
up vote
0
down vote
up vote
0
down vote
In short, you can't do that in android, because if you see the docs about shadow only Support IOS see doc
The best option you can install 3rd party react-native-shadow
In short, you can't do that in android, because if you see the docs about shadow only Support IOS see doc
The best option you can install 3rd party react-native-shadow
answered Nov 11 at 14:04
Muhammad Al Faris
11
11
add a comment |
add a comment |
up vote
0
down vote
Set elevation: 3 and you should see the shadow in bottom of component without a 3rd party lib. At least in RN 0.57.4
add a comment |
up vote
0
down vote
Set elevation: 3 and you should see the shadow in bottom of component without a 3rd party lib. At least in RN 0.57.4
add a comment |
up vote
0
down vote
up vote
0
down vote
Set elevation: 3 and you should see the shadow in bottom of component without a 3rd party lib. At least in RN 0.57.4
Set elevation: 3 and you should see the shadow in bottom of component without a 3rd party lib. At least in RN 0.57.4
answered Nov 12 at 9:55
C-lio Garcia
1056
1056
add a comment |
add a comment |
up vote
0
down vote
I had the same problem shadow/elevation not showing on Android with elevation:2. Then i noticed that the view element is fool width, so I added margin:2 to the view element and elevation properly appeared.
Style:
margin: 2,
shadowColor: '#000',
shadowOffset:
width: 0,
height: 1
,
shadowOpacity: 0.2,
shadowRadius: 1.41,
elevation: 2
Android:
iOS:
add a comment |
up vote
0
down vote
I had the same problem shadow/elevation not showing on Android with elevation:2. Then i noticed that the view element is fool width, so I added margin:2 to the view element and elevation properly appeared.
Style:
margin: 2,
shadowColor: '#000',
shadowOffset:
width: 0,
height: 1
,
shadowOpacity: 0.2,
shadowRadius: 1.41,
elevation: 2
Android:
iOS:
add a comment |
up vote
0
down vote
up vote
0
down vote
I had the same problem shadow/elevation not showing on Android with elevation:2. Then i noticed that the view element is fool width, so I added margin:2 to the view element and elevation properly appeared.
Style:
margin: 2,
shadowColor: '#000',
shadowOffset:
width: 0,
height: 1
,
shadowOpacity: 0.2,
shadowRadius: 1.41,
elevation: 2
Android:
iOS:
I had the same problem shadow/elevation not showing on Android with elevation:2. Then i noticed that the view element is fool width, so I added margin:2 to the view element and elevation properly appeared.
Style:
margin: 2,
shadowColor: '#000',
shadowOffset:
width: 0,
height: 1
,
shadowOpacity: 0.2,
shadowRadius: 1.41,
elevation: 2
Android:
iOS:
answered Nov 25 at 13:36
Kristijan Tomić
414
414
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41320131%2fhow-to-set-shadows-in-react-native-for-android%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown