Fullscreen Mode using ActionBarSherlock on Devices running API <11

余生长醉 提交于 2020-01-01 10:56:08

问题


Is there a way to go in fullscreen mode using ActionBarSherlock on Devices running API <11?

Further Information:

My app is using ActionBarSherlock and while testing on different devices i stumbled on a problem.

If i try tro launch an activity in fullscreen

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 

on a Device running on a API lower than 11 the following error occured:

 05-29 10:12:54.436: E/AndroidRuntime(1034): FATAL EXCEPTION: main
 05-29 10:12:54.436: E/AndroidRuntime(1034): java.lang.RuntimeException: Unable to   start activity      ComponentInfo{de.osthessennews.osthessennewsapp/com.example.listview.PlayVideo}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light,   Theme.Sherlock.Light.DarkActionBar, or a derivative.

The error occurs, cuz the Line in the Manifest isn't supported for Devices running on API's < 11.

So i know what is causing the problem, but i dont know how to resolve it. I hope one of you guys can help me.

Manifest Snipped:

 <application
    android:allowBackup="true"  
    android:icon="@drawable/ic_launcher"       
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock" >
    >   

回答1:


You Can do Programmatically :

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

Use before setContentView().




回答2:


The latest version of ABS (ActionBar Sherlock) still does not have a Theme.Sherlock.Light.NoActionBar or Theme.Sherlock.Light.NoActionBar.Fullscreen but you can always create a Fullscreen activity by hiding the ActionBar programmatically as explained on the previous answer.

But if you want to create a theme or style, include

<item name="android:windowFullscreen">true</item>

on it, but that will only hide Android's status bar.

To hide the ActionBar in your activities (extending from SherlockActivity or SherlockFragmentActivity) code:

getSupportActionBar().hide();

That will give you a NoActionBar.Fullscreen effect.



来源:https://stackoverflow.com/questions/16811951/fullscreen-mode-using-actionbarsherlock-on-devices-running-api-11

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