微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 试图隐藏标题栏时应用程序崩溃

为了制作全屏幕应用程序,我对新的“空白活动”项目的清单进行了以下更改:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

在任何设备上运行时,应用程序崩溃.我所做的更改已被StackOverflow中的许多帖子推荐,我无法弄清楚我做错了什么.

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    <activity
        android:name="com.example.app.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>
</manifest>

解决方法

只是在下面做:
import android.support.v7.app.ActionBaractivity;

延伸:

public class SplashScreen extends ActionBaractivity {

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            getSupportActionBar().hide();
            setContentView(R.layout.splash_screen);
    }
}

它的工作正常,API等级为7或更高.

编辑:

使用AppCompatActivity,因为ActionBaractivity @deprecated在API 23中.

原文地址:https://www.jb51.cc/android/315986.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐