0

我想在我的应用程序中实现全屏。我发现这段代码可以做到这一点:

public class FullScreen extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);
}
}

或通过 AndroidManifest.xml

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

好吧,没有人去。当我启动它时,两者都会使我的应用程序崩溃。错误是“不幸的是应用程序已停止”。有谁知道这个问题?

4

3 回答 3

2

尝试使用此代码使您的活动 FULL_SCREEN

  1. 在 res\values\ 中寻找 find:styles.xml 添加

    <style name="NoTitle" parent="AppBaseTheme">
        <item name="android:windowNoTitle">true</item>
    </style>    
    

  2. 打开文件 Manifest 寻找应用程序

添加

android:theme="@style/NoTitle">

看起来像:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/NoTitle" >
于 2013-05-23T07:55:56.790 回答
0

将您的代码放在 super.onCreate(savedInstanceState) 之前

于 2013-05-31T00:07:17.727 回答
0

这对我有用。

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>

于 2015-09-22T01:49:46.680 回答