Removing Title Bar in Android 2.3 (Gingerbread) causes problem with SurfaceView

我们两清 提交于 2019-12-24 09:05:42

问题


Anyone experiencing a problem with their app in Gingerbread? -- if you use

requestWindowFeature(Window.FEATURE_NO_TITLE);

And you switch to another window, when you come back it changes the dimensions of the surfaceview.

For now, I've put the titlebar back in to work around this issue.

Thanks for any help Mark


回答1:


Yes, we too have experienced this after updating to Android 2.3.4. To fix it in our apps we eliminated the requestWindowFeature(Window.FEATURE_NO_TITLE); in our apps and then utilized a styles.xml, saved in the project's values folder with the following:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.Transparent" parent="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">"
    <item name="android:windowBackground">@color/background</item>
</style>

Here a colors.xml will be utilized to set the @color/background, which is also saved in the project's value folder with the following:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <color name ="background">#000000</color>
</resources>

Then in the manifest file we utilized:

<application android:label="@string/app_name"
    android:icon="@drawable/icon"
    android:theme="@style/Theme.Transparent"
>

to apply the theme to the application as a whole. Perhaps others will have better suggestions and also maybe a reason for why this occurs in Gingerbread as in Froyo the requestWindowFeature(Window.FEATURE_NO_TITLE); worked well with SurfaceViews.



来源:https://stackoverflow.com/questions/6642192/removing-title-bar-in-android-2-3-gingerbread-causes-problem-with-surfaceview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!