今日在作项目时出现了gralloc out of memory的错误,通过几日的测试调整,最终肯定是在AndroidManifest.xml中使用了android:theme="@android:style/Theme.Translucent.NoTitleBar" 的配置项致使的,因此在隐藏titlebar时,不建议使用该方法。java
通过试验,使用一下方式能够达到一样效果,且不会出现oom的错误。android
在onCreate方法中调用:app
requestWindowFeature(Window.FEATURE_NO_TITLE);
而后再在style.xml中配置:测试
<style name="Theme.MyTheme" parent="android:style/Theme.Translucent"> <item name="android:windowContentOverlay">@null</item> </style>
最后在AndroidManifest.xml的application配置:code
<application android:icon="@drawable/n_icon" android:label="@string/app_name" android:theme="@style/Theme.MyTheme">通过以上设置,可避免oom错误,同时实现隐藏titlebar的效果。