Image使用本地資源不顯示問題:
看看官方說法:
Any time you add a new resource to your drawables you will need to re-build your app by running react-native run-android before you can use it - reloading the JS is not enough.
也就是說當你新加入了資源後要重新打包並執行 react-native run-android命令
猜想:因爲Android有一個獨有的資源管理系統,它會將資源索引改成id對應文件名的方式放在resc文件裏,最後打成安裝包。
解決辦法:使用uri的方式可以讓圖片實時下載並更新。
問題二:
React Native ScollView不能滑動的問題
ScrollView是必須要設置height的
那麼下一個問題來了。怎麼在Css中表示matchparent?
我試了一下100%,不過好像並沒有什麼用
解決辦法
var Dimensions = require('Dimensions');
var windowSize = Dimensions.get('window');
scrollView: {
backgroundColor: '#6A85B1',
height: windowSize.height-25,
},
爲什麼要減25呢。你得到的高度是屏幕的高度,要得到ScrollView的高度就要減去屏幕最頂部通知欄的高度。