2017-04-12 39 views
0

工作,我使用下面的風格在組件上:的ShadowOffset不會在Android

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 
    } 
}; 

陰影不會被渲染。 enter image description here

有人能告訴我爲什麼嗎?

回答

4

正如A. Goodale所說,影子道具只適用於iOS。使用Android,您可以在視圖樣式中使用elevation

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

謝謝,它適合我。 –

4

根據this page,陰影道具只在iOS上實現。

+0

感謝您的信息的人。 –