我可以对由最新版本的 Android Studio 创建的新空白 Activity 进行的最简单更改是什么,以使应用程序显示为全屏?
我想创建一个全屏 Android 应用程序。我正在使用 Android Studio。 这篇文章建议我添加一行,例如...
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"
...到AndroidManifest.xml文件,如下图:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lexogram.james.blackslate" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.lexogram.james.blackslate.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
当我这样做时,应用程序编译但它在启动时崩溃。如果我删除该行,应用程序运行良好,但有操作栏和标题栏,正如其他用户所指出的那样。
这是我第一次尝试创建 Android 应用程序,因此我的应用程序与最初的 Hello World 示例几乎没有改变。
编辑:我创建了一个新项目,并对其进行了一次更改。以下是错误日志的摘录:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lexogram.james.test/com.lexogram.james.test.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)...
注意:我正在运行 Android 2.2 (Froyo) 的旧三星 SGH-T499Y 上进行测试