我刚开始"真实" android编程(以前用Unity3D编程)今天。我做了一个非常简单的应用程序设计,现在我希望它是全屏的。我搜索了它,发现了这段代码:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
但这不适用于我的应用。当我尝试启动我的应用程序时,我收到了错误:"我的应用程序已经过去了#34;。这应该是"我的应用程序已退出"用英语讲。 当我只将这一行改为以下内容时,我的应用程序运行良好:
android:theme="@style/AppTheme"
我不会更改除此单行以外的任何其他内容,因此问题应该由此行引起。我究竟做错了什么?这就是我的清单文件完整的样子,也许它可以提供帮助:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dunkel.jonas.myapplication" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
感谢您的帮助!
编辑:
这是logcat:
05-13 12:44:42.395 12101-12101/com.dunkel.jonas.myapplication I/art﹕ Late-enabling -Xcheck:jni
05-13 12:44:42.511 12101-12101/com.dunkel.jonas.myapplication D/AndroidRuntime﹕ Shutting down VM
05-13 12:44:42.512 12101-12101/com.dunkel.jonas.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.dunkel.jonas.myapplication, PID: 12101
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dunkel.jonas.myapplication/com.dunkel.jonas.myapplication.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2329)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access$900(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.dunkel.jonas.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:5938)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.access$900(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
&#13;
答案 0 :(得分:1)
使用您正在使用的活动是从支持库中请求主题。
java.lang.IllegalStateException:您需要使用Theme.AppCompat主题
你可以试试这个。
<application
...
android:theme="@style/Theme.AppCompat.NoActionBar" >
</application>
答案 1 :(得分:0)
在Android_manifest.xml中,在应用程序级别put,
<activity
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
...
</activity>
并且在要进行全屏显示的活动中
or build target