Morton
Morton

Reputation: 5760

The ShadowOffset doesn't work on Android

I use the following style on a component:

const styles = {
    viewStyle: {
        backgroundColor: '#F8F8F8',
        justifyContent: 'center',
        alignItems: 'center',
        height: 60,
        paddingTop: 15,
        shadowColor: '#000',//About the shadow setting
        shadowOffset: { width: 0, height: 2 },//About the shadow setting
        shadowOpacity: 0.2,//About the shadow setting
    },
    textStyle: {
        fontSize: 20
    }
};

The shadow doesn't get rendered. enter image description here

Can someone tell me why?

Upvotes: 0

Views: 1605

Answers (2)

Antoine Grandchamp
Antoine Grandchamp

Reputation: 7470

As A. Goodale said, shadow props are only for iOS. With Android, you can use elevation in your View style.

viewStyle: {
    backgroundColor: '#F8F8F8',
    justifyContent: 'center',
    alignItems: 'center',
    height: 60,
    paddingTop: 15,
    elevation: 4,
},

Upvotes: 4

A. Goodale
A. Goodale

Reputation: 1348

According to this page, the shadow props are only implemented on iOS.

Upvotes: 4

Related Questions