2
I’m breaking my head here to hide the bar that gives the name of the app...
I’ve tried everything I’ve seen on the Internet, nothing works... and when I change the android:theme="@style/AppTheme"
for android:theme="@android:style/Theme.NoTitleBar"
the application stops working I do not understand for what reason, so what I have done so far is to change the java file to hide the title bar, tamper with Styles.xml to hide the title bar.
My minimum API is 15 (Android 4.0.3)
Androidmanifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.knautiluz.feralbytes">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Styles:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Activity:
package com.knautiluz.feralbytes;
import android.content.pm.ActivityInfo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Tudo que ocorre no inicio do app > Fica em tela cheia
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
CRASH:
--------- Beginning of crash
06-26 23:13:44.705 2373-2373/com.knautiluz.feralbytes E/Androidruntime: FATAL EXCEPTION: main Process: com.knautiluz.feralbytes, PID: 2373 java.lang.Runtimeexception: Unable to start Activity Componentinfo{com.knautiluz.feralbytes/com.knautiluz.feralbytes.Mainactivity}: java.lang.Illegalstateexception: You need to use a Theme.Appcompat Theme (or Descendant) with this Activity. at android.app.Activitythread.performLaunchActivity(Activitythread.java:2416) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2476) at android.app.Activitythread. -wrap11(Activitythread.java) at android.app.Activitythread$H.handleMessage(Activitythread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.Activitythread.main(Activitythread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:726) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:616) Caused by: java.lang.Illegalstateexception: You need to use a Theme.Appcompat Theme (or Descendant) with this Activity. at android.support.v7.app.Appcompatdelegateimplv7.createSubDecor(Appcompatdelegateimplv7.java:343) at android.support.v7.app.Appcompatdelegateimplv7.ensureSubDecor(Appcompatdelegateimplv7.java:312) at android.support.v7.app.Appcompatdelegateimplv7.setContentView(Appcompatdelegateimplv7.java:277) at android.support.v7.app.Appcompatactivity.setContentView(Appcompatactivity.java:140) at com.knautiluz.feralbytes.MainActivity.onCreate(Mainactivity.java:15) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.Activitythread.performLaunchActivity(Activitythread.java:2369) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2476) at android.app.Activitythread. -wrap11(Activitythread.java) at android.app.Activitythread$H.handleMessage(Activitythread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.Activitythread.main(Activitythread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:726) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:616)
I would like to know first what causes this crash when changing the android:theme="@style/AppTheme"
for `android:Theme="@android:style/Theme.Notitlebar"
Can log the error that occurs?
– Marco Giovanni
@Marcogiovanni Ready put! I think it’s this log...
– Raizant
I don’t know if it helps, but I’m using Empty Activity by default
– Raizant