Reputation: 61
I've try to change my manifest, using @android:style/Theme.NoTitleBar
and also change onCreate()
method but my app always crashes.
this is my manifest:
<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"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and my MainActivity():
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Upvotes: 2
Views: 55
Reputation: 5087
Your MainActivity
class extends from AppCompatActivity
. So is required that MainActivity
theme must be Theme.AppCompat theme (or descendant)
So make your theme AppTheme.NoActionBar
extends from Theme.AppCompat
like this:
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
...
</style>
Hope this helps!!
Upvotes: 2
Reputation: 148
In styles use this code:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
And use this theme name in AndroidManifest.xml in Application tag:
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 1