工做中會遇到各類各樣的問題,ReactNative開發也是填坑不止。
好比最近在開發需求中,就遇到一個問題。在一個卡片類型的右上角添加一個刪除按鈕。使用了絕對佈局position:'absolute'屬性,在Android上卻沒法正常顯示,非常煩惱。
有一個相關的issue:https://github.com/facebook/r...
正常但願的展現效果:react
可是實際效果是:git
能夠看到,綠色的view被遮擋了。
查閱相關資料和嘗試以後,能夠使用position:'absolute' 和zIndex結合使用解決這個問題。
最後貼一下,相關代碼。github
<View style={{ position: 'absolute', zIndex: 99999, justifyContent: 'center', alignItems: 'center', top: 10, width: 30, height: 30, elevation: 99999 }}> <Image source={require('images/compared/delete_gray.png')} /> </View>