本文實例講述了Android編程中activity啟動時出現白屏、黑屏問題的解決方法。分享給大家供大家參考,具體如下:
默認情況下 activity 啟動的時候先把屏幕刷成白色,再繪制界面,繪制界面或多或少有點延遲,這段時間中你看到的就是白屏,顯然影響用戶體驗,怎么消除呢?
在 Activity theme 設置style 即可
<style name="AppTheme" parent="android:Theme.Light.NoTitleBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowActionBar">false</item> <item name="android:windowBackground">@android:color/transparent</item> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style>
<application android:name="com.skymobi.moposns.MyApplication" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.skymobi.moposns.MainActivity" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
希望本文所述對大家Android程序設計有所幫助。
新聞熱點
疑難解答
圖片精選