android - 全屏Android "Unfortunately application has stopped"为什么?

标签 android crash android-fullscreen

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

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"

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

最佳答案

尝试使用此代码使您的 Activity FULL_SCREEN

  • 在 res\values\中寻找 find:styles.xml 添加
    <style name="NoTitle" parent="AppBaseTheme">
        <item name="android:windowNoTitle">true</item>
    </style>    
    

  • 打开文件 list
    找申请

  • 添加
    android:theme="@style/NoTitle">
    

    看起来像:
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/NoTitle" >
    

    关于android - 全屏Android "Unfortunately application has stopped"为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16708372/

    相关文章:

    Android 应用程序在单击按钮后失败并停止

    libdispatch _dispatch_semaphore_wait_slow 中的崩溃

    ios - 无法解决崩溃 EXC_CRASH (SIGABRT)

    android - 使用全屏 Activity

    Android 沉浸式模式和向后兼容性

    java - 使用 Traces.txt 了解 ANR 错误

    android - 将滚动 fragment 设置为滚动 Activity

    java - 在 Android 布局调用中使用变量

    iphone - 我如何告诉 iOS 我不希望该应用程序留在后台?

    javascript - 强制 Chrome (38) 退出全屏模式