每個人總會在開發中遇到很多小問題,都記住不太現實,但是百度谷歌又浪費時間了,隨手記錄一下,方便以後使用
1.ButterKnide報 空指針 或者 IllegalStateException
Caused by: java.lang.IllegalStateException: Required view 'iv_splash' with ID 2131427415 for field 'ivSplash' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
原因是ButterKnife 在8.0之後有過改版,在BaseActivity中配置 ButterKnife.bind(this) 不行了;BaseActivity中不綁定了,在Activity中去綁定就好了
2.解決App啓動時會有以下黑屏的問題
避免黑色閃屏有2種方法,分別爲:1.爲 Theme 設置背景圖;2.爲 Theme 設置透明屬性。
第一種:
<!-- 爲 Theme 設置背景圖 -->
<style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowBackground">@drawable/splash_bg</item>
</style>`
第二種:
<!-- 爲 Theme 設置透明屬性 -->
<style name="AppTheme" parent="android:style/Theme.Black.NoTitleBar.Fullscreen">
<item name="android:windowIsTranslucent">true</item>
</style>